-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into issue-412-part-2
- Loading branch information
Showing
6 changed files
with
167 additions
and
146 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 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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
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,29 @@ | ||
""" | ||
collect all notebooks in examples, and check that they run without error | ||
""" | ||
|
||
import nbformat | ||
from nbconvert.preprocessors import ExecutePreprocessor | ||
from pathlib import Path | ||
from glob import glob | ||
this_file_loc = Path(__file__).parent | ||
|
||
def check_notebook_runs(notebook_loc): | ||
|
||
try: | ||
with open(notebook_loc, encoding='utf8') as f: | ||
nb = nbformat.read(f, as_version=4) | ||
ep = ExecutePreprocessor(timeout=600, kernel_name='python3') | ||
ep.preprocess(nb, {'metadata': {'path': Path(notebook_loc).parent}}) | ||
except Exception as e: | ||
print(f'failed to run notebook {notebook_loc}: rethrowing exception:') | ||
raise e | ||
|
||
def test_all_notebooks_run(): | ||
# get all notebooks: | ||
notebooks = glob(str(this_file_loc.parent / 'examples' / '*.ipynb')) | ||
notebooks_not_to_run = ['put_notebooks_to_skip_here'] | ||
for notebook in notebooks: | ||
if any([nb in notebook for nb in notebooks_not_to_run]): | ||
continue | ||
check_notebook_runs(notebook) |