Skip to content

Commit

Permalink
Make updating run notebook optional
Browse files Browse the repository at this point in the history
  • Loading branch information
ajparsons committed Aug 7, 2023
1 parent 8ea4cf7 commit f1f8eb1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/data_common/management/run_notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pathlib import Path


def run_notebook(notebook_filename: Path):
def run_notebook(notebook_filename: Path, save: bool = True):
"""
Run a notebook as part of another process
"""
Expand All @@ -12,6 +12,8 @@ def run_notebook(notebook_filename: Path):
nb = nbformat.read(f, as_version=4)
ep = ExecutePreprocessor(timeout=600)
ep.preprocess(nb, {"metadata": {"path": "notebooks/"}})
with open(notebook_filename, "w", encoding="utf-8") as f:
nbformat.write(nb, f)
if save:
print(f"Saving notebook: {notebook_filename}")
with open(notebook_filename, "w", encoding="utf-8") as f:
nbformat.write(nb, f)
print("Done")

0 comments on commit f1f8eb1

Please sign in to comment.