Skip to content

Commit 9f3f2e7

Browse files
authored
Merge pull request #148 from mwcraig/reorg-03
Move content from notebooks 03.X and 04.X into folder 03.
2 parents d46caff + ddba6b4 commit 9f3f2e7

File tree

8 files changed

+42
-3
lines changed

8 files changed

+42
-3
lines changed

notebooks/04.00-widget-list.ipynb renamed to notebooks/04.WidgetList/04.00-widget-list.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
"metadata": {},
117117
"outputs": [],
118118
"source": [
119-
"# %load solutions/interact-basic-list/bounded-float-text.py"
119+
"# %load solutions/bounded-float-text.py"
120120
]
121121
},
122122
{
@@ -134,7 +134,7 @@
134134
"metadata": {},
135135
"outputs": [],
136136
"source": [
137-
"# %load solutions/interact-basic-list/widgets-in-a-box.py"
137+
"# %load solutions/widgets-in-a-box.py"
138138
]
139139
},
140140
{

notebooks/04.01-more-on-output-widget.ipynb renamed to notebooks/04.WidgetList/04.01-more-on-output-widget.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@
322322
"metadata": {},
323323
"outputs": [],
324324
"source": [
325-
"# %load solutions/output/sidecar-triple.py"
325+
"# %load solutions/sidecar-triple.py"
326326
]
327327
},
328328
{
File renamed without changes.

tools/execute_notebooks.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
"""
2+
Iterate through and execute all notebooks
3+
"""
4+
from pathlib import Path
5+
6+
import nbformat as nbf
7+
from nbconvert.preprocessors import ExecutePreprocessor
8+
9+
10+
def main():
11+
p = Path('.')
12+
notebook_paths = p.glob('**/*.ipynb')
13+
exceptions = {}
14+
for nb_path in notebook_paths:
15+
if '.ipynb_checkpoints' in str(nb_path):
16+
continue
17+
print(nb_path)
18+
notebook = nbf.read(nb_path, 4)
19+
try:
20+
ep = ExecutePreprocessor()
21+
print('About to execute')
22+
ep.preprocess(notebook)
23+
print('Done executing')
24+
except Exception as e:
25+
exceptions[str(nb_path)] = e
26+
27+
if exceptions:
28+
print('⚠️' * 20)
29+
print('\n\nFailures in these notebooks:')
30+
print('\n'.join(exceptions.keys()), '\n\n')
31+
print('⚠️' * 20)
32+
for nb, error in exceptions.items():
33+
print(f'{nb}: \n{error}')
34+
else:
35+
print('🎉🎉 Everything worked! 🎉🎉')
36+
37+
38+
if __name__ == '__main__':
39+
main()

0 commit comments

Comments
 (0)