Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mitch/fix if statement #2696

Merged
merged 7 commits into from
Mar 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions docs/notebook_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# the terms of the Apache License 2.0 which accompanies this distribution. #
# ============================================================================ #

import time
import os
import re
import sys
Expand Down Expand Up @@ -42,11 +43,14 @@ def execute(notebook_filename):
notebook_filename_out = notebook_filename.replace('.ipynb',
'.nbconvert.ipynb')
try:
start_time = time.perf_counter()
subprocess.run([
"jupyter", "nbconvert", "--to", "notebook", "--execute",
notebook_filename
],
check=True)
elapsed = time.perf_counter() - start_time
print(f"Time taken for nbconvert: {elapsed:.2f} seconds")
os.remove(notebook_filename_out)
return True
except subprocess.CalledProcessError:
Expand Down Expand Up @@ -98,21 +102,23 @@ def print_results(success, failed, skipped=[]):

notebooks_success, notebooks_skipped, notebooks_failed = (
[] for i in range(3))

## `afqmc`:
## See: https://github.com/NVIDIA/cuda-quantum/issues/2577
## `quantum_transformer`:
## See: https://github.com/NVIDIA/cuda-quantum/issues/2689
notebooks_skipped = ['afqmc.ipynb', 'quantum_transformer.ipynb']

for notebook_filename in notebook_filenames:
## See: https://github.com/NVIDIA/cuda-quantum/issues/2577
if os.path.basename(notebook_filename) in ["afqmc.ipynb"]:
notebooks_skipped.append(notebook_filename)
## See: https://github.com/NVIDIA/cuda-quantum/issues/2689
if os.path.basename(notebook_filename) in [
"quantum_transformer.ipynb"
]:
notebooks_skipped.append(notebook_filename)
elif (validate(notebook_filename, available_backends)):
if (execute(notebook_filename)):
notebooks_success.append(notebook_filename)
else:
notebooks_failed.append(notebook_filename)
base_name = os.path.basename(notebook_filename)
if base_name in notebooks_skipped:
continue # Already skipped, no need to re-check
if not validate(notebook_filename, available_backends):
notebooks_skipped.append(base_name)
continue
if execute(notebook_filename):
notebooks_success.append(notebook_filename)
else:
notebooks_skipped.append(notebook_filename)
notebooks_failed.append(notebook_filename)

print_results(notebooks_success, notebooks_failed, notebooks_skipped)
Loading