-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathrun_notebooks.py
26 lines (22 loc) · 922 Bytes
/
run_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
import papermill as pm
import os
def execute_notebooks(notebooks_directory):
#disable
return None
# Delete existing -out.ipynb files
for filename in os.listdir(notebooks_directory):
if filename.endswith("-out.ipynb"):
os.remove(os.path.join(notebooks_directory, filename))
# Execute notebooks and save with -out.ipynb suffix
for filename in os.listdir(notebooks_directory):
if filename.endswith(".ipynb") and not filename.endswith("-out.ipynb"):
input_path = os.path.join(notebooks_directory, filename)
output_path = os.path.join(notebooks_directory, filename.replace(".ipynb", "-out.ipynb"))
pm.execute_notebook(
input_path,
output_path,
log_output=True,
)
if __name__ == "__main__":
notebooks_directory = 'notebooks'
execute_notebooks(notebooks_directory)