forked from pypest/pyemu_pestpp_workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautotest_notebooks.py
35 lines (26 loc) · 885 Bytes
/
autotest_notebooks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Remove the temp directory and then create a fresh one
import os
import shutil
import pyemu
def get_notebooks():
return [f for f in os.listdir(".") if f.endswith('.ipynb')]
def run_notebook(fn):
#pth = os.path.join(nbdir, fn)
pth = fn
cmd = 'jupyter ' + 'nbconvert ' + \
'--ExecutePreprocessor.kernel_name=python ' + \
'--ExecutePreprocessor.timeout=6000 ' + '--to ' + 'notebook ' + \
'--execute ' + '{} '.format(pth) + \
'--output ' + '{}'.format(fn)
#ival = os.system(cmd)
ival = pyemu.os_utils.run(cmd,cwd=nbdir)
print(ival,cmd)
assert ival == 0 or ival is None, 'could not run {}'.format(fn)
def test_notebooks():
files = get_notebooks()
for fn in files:
yield run_notebook, fn
if __name__ == '__main__':
files = get_notebooks()
for fn in files:
run_notebook(fn)