Skip to content

Commit 688f22c

Browse files
committed
[no ci] notebook tests: increase timeout, fix platform/backend dependent code
Torch is very slow, so I had to increase the timeout accordingly.
1 parent 5434666 commit 688f22c

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

examples/From_ABC_to_BayesFlow.ipynb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@
3838
"outputs": [],
3939
"source": [
4040
"import numpy as np\n",
41-
"import matplotlib.pyplot as plt"
41+
"import matplotlib.pyplot as plt\n",
42+
"import tempfile\n",
43+
"from pathlib import Path\n",
44+
"import platform"
4245
]
4346
},
4447
{
@@ -322,7 +325,9 @@
322325
")\n",
323326
"\n",
324327
"# generate a temporary SQLite DB\n",
325-
"abc_id = abc.new(\"sqlite:////tmp/mjp.db\", observations)"
328+
"prefix = \"sqlite:///\" if platform.system() == \"Windows\" else \"sqlite:////\"\n",
329+
"db_path = (Path(tempfile.gettempdir()).absolute() / \"mjp.db\").as_uri().replace(\"file:///\", prefix)\n",
330+
"abc_id = abc.new(db_path, observations)"
326331
]
327332
},
328333
{

examples/SIR_Posterior_Estimation.ipynb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919
"source": [
2020
"import os\n",
2121
"# Set to your favorite backend\n",
22-
"os.environ[\"KERAS_BACKEND\"] = \"jax\""
22+
"if \"KERAS_BACKEND\" not in os.environ:\n",
23+
" # set this to \"torch\", \"tensorflow\", or \"jax\"\n",
24+
" os.environ[\"KERAS_BACKEND\"] = \"tensorflow\"\n",
25+
"else:\n",
26+
" print(f\"Using '{os.environ['KERAS_BACKEND']}' backend\")"
2327
]
2428
},
2529
{

examples/Two_Moons_Starter.ipynb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@
2424
"source": [
2525
"import os\n",
2626
"# Set to your favorite backend\n",
27-
"os.environ[\"KERAS_BACKEND\"] = \"jax\""
27+
"if \"KERAS_BACKEND\" not in os.environ:\n",
28+
" # set this to \"torch\", \"tensorflow\", or \"jax\"\n",
29+
" os.environ[\"KERAS_BACKEND\"] = \"tensorflow\"\n",
30+
"else:\n",
31+
" print(f\"Using '{os.environ['KERAS_BACKEND']}' backend\")"
2832
]
2933
},
3034
{

tests/utils/jupyter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ def run_notebook(path):
1010
checkpoint_path = path.parent / "checkpoints"
1111
# only clean up if the directory did not exist before the test
1212
cleanup_checkpoints = not checkpoint_path.exists()
13-
with open(str(path)) as f:
13+
with open(str(path), encoding="utf-8") as f:
1414
nb = nbformat.read(f, nbformat.NO_CONVERT)
1515

16-
kernel = ExecutePreprocessor(timeout=600, kernel_name="python3", resources={"metadata": {"path": path.parent}})
16+
kernel = ExecutePreprocessor(timeout=3600, kernel_name="python3", resources={"metadata": {"path": path.parent}})
1717

1818
try:
1919
result = kernel.preprocess(nb)

0 commit comments

Comments
 (0)