File tree Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change 33from tests .utils import run_notebook
44
55
6+ @pytest .mark .skip (reason = "requires setting up Stan" )
67@pytest .mark .slow
78def test_bayesian_experimental_design (examples_path ):
89 run_notebook (examples_path / "Bayesian_Experimental_Design.ipynb" )
910
1011
11- @pytest .mark .skip (reason = "Requires setting up Stan." )
1212@pytest .mark .slow
1313def test_from_abc_to_bayesflow (examples_path ):
1414 run_notebook (examples_path / "From_ABC_to_BayesFlow.ipynb" )
Original file line number Diff line number Diff line change 22from nbconvert .preprocessors import ExecutePreprocessor
33
44from pathlib import Path
5+ import shutil
56
67
78def run_notebook (path ):
9+ path = Path (path )
10+ checkpoint_path = path .parent / "checkpoints"
11+ # only clean up if the directory did not exist before the test
12+ cleanup_checkpoints = not checkpoint_path .exists ()
813 with open (str (path )) as f :
914 nb = nbformat .read (f , nbformat .NO_CONVERT )
1015
11- kernel = ExecutePreprocessor (
12- timeout = 600 , kernel_name = "python3" , resources = {"metadata" : {"path" : Path (path ).parent }}
13- )
16+ kernel = ExecutePreprocessor (timeout = 600 , kernel_name = "python3" , resources = {"metadata" : {"path" : path .parent }})
17+
18+ try :
19+ result = kernel .preprocess (nb )
20+ except Exception as e :
21+ raise e
22+ finally :
23+ if cleanup_checkpoints and checkpoint_path .exists ():
24+ # clean up if the directory was created by the test
25+ shutil .rmtree (checkpoint_path )
1426
15- result = kernel .preprocess (nb )
1627 return result
You can’t perform that action at this time.
0 commit comments