File tree Expand file tree Collapse file tree 6 files changed +157
-144
lines changed
Expand file tree Collapse file tree 6 files changed +157
-144
lines changed Original file line number Diff line number Diff line change 11# This workflow will install Python dependencies, run tests and lint with a single version of Python
22# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
33
4-
54name : tests
65
76on :
@@ -27,14 +26,21 @@ jobs:
2726 uses : actions/setup-python@v3
2827 with :
2928 python-version : ${{ matrix.python-version }}
30- - name : Install dependencies
29+ - name : Install test dependencies
3130 run : |
3231 python -m pip install --upgrade pip
3332 pip install pytest
3433 pip install pytest-cov
3534 pip install coverage
35+ - name : Install notebook dependencies
36+ run : |
37+ pip install nbformat
38+ pip install nbconvert
39+ pip install jupyter
40+ pip install matplotlib
41+ - name : Install package
42+ run : |
3643 pip install -e .
37-
3844 - name : Test with pytest
3945 run : |
4046 pytest --cov-report xml --cov=bayes_opt/
Original file line number Diff line number Diff line change 491491 ],
492492 "metadata" : {
493493 "kernelspec" : {
494- "display_name" : " Python 3" ,
494+ "display_name" : " Python 3 (ipykernel) " ,
495495 "language" : " python" ,
496496 "name" : " python3"
497497 },
505505 "name" : " python" ,
506506 "nbconvert_exporter" : " python" ,
507507 "pygments_lexer" : " ipython3" ,
508- "version" : " 3.5.2 "
508+ "version" : " 3.9.6 "
509509 }
510510 },
511511 "nbformat" : 4 ,
Load Diff Large diffs are not rendered by default.
Load Diff Large diffs are not rendered by default.
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change 1+ """
2+ collect all notebooks in examples, and check that they run without error
3+ """
4+
5+ import nbformat
6+ from nbconvert .preprocessors import ExecutePreprocessor
7+ from pathlib import Path
8+ from glob import glob
9+ this_file_loc = Path (__file__ ).parent
10+
11+ def check_notebook_runs (notebook_loc ):
12+
13+ try :
14+ with open (notebook_loc , encoding = 'utf8' ) as f :
15+ nb = nbformat .read (f , as_version = 4 )
16+ ep = ExecutePreprocessor (timeout = 600 , kernel_name = 'python3' )
17+ ep .preprocess (nb , {'metadata' : {'path' : Path (notebook_loc ).parent }})
18+ except Exception as e :
19+ print (f'failed to run notebook { notebook_loc } : rethrowing exception:' )
20+ raise e
21+
22+ def test_all_notebooks_run ():
23+ # get all notebooks:
24+ notebooks = glob (str (this_file_loc .parent / 'examples' / '*.ipynb' ))
25+ notebooks_not_to_run = ['put_notebooks_to_skip_here' ]
26+ for notebook in notebooks :
27+ if any ([nb in notebook for nb in notebooks_not_to_run ]):
28+ continue
29+ check_notebook_runs (notebook )
You can’t perform that action at this time.
0 commit comments