-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CI: switch to testing example .py files instead of notebooks
- Loading branch information
Showing
3 changed files
with
52 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
""" | ||
Code to execute code examples notebooks in /docs/examples. | ||
This will not be run through pytest but is meant to be run in a separate CI job. | ||
""" | ||
|
||
import subprocess | ||
from pathlib import Path | ||
|
||
# If Jupyter is not installed, this will fail. | ||
# We will belay the import error in case the | ||
# user wants to run only the other parts of the | ||
# test suite. | ||
try: | ||
import nbformat | ||
from nbconvert.preprocessors import ExecutePreprocessor | ||
except ImportError: | ||
nbformat = None | ||
pass | ||
except BaseException: | ||
raise | ||
|
||
SKIP = [ | ||
|
||
] | ||
|
||
if __name__ == "__main__": | ||
# Recursively search for notebooks | ||
path = Path(__file__).parent.parent / "docs/examples" | ||
|
||
files = list(path.rglob("*.py")) | ||
for i, file in enumerate(files): | ||
if not file.is_file(): | ||
continue | ||
if file.name in SKIP: | ||
continue | ||
|
||
print(f"Executing {file.name} [{i+1}/{len(files)}]... ", end="", flush=True) | ||
try: | ||
p = subprocess.run(["python", str(file)], check=True, capture_output=True, timeout=600) | ||
except subprocess.CalledProcessError as e: | ||
print("Failed.") | ||
print(e.stdout.decode()) | ||
print(e.stderr.decode()) | ||
raise | ||
print("Done.", flush=True) | ||
|
||
print("All done.") |