Created
September 21, 2021 20:09
-
-
Save subwaymatch/19b4521cc7501b6ade83e6da07a09fad to your computer and use it in GitHub Desktop.
Run Jupyter notebooks as a batch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import glob | |
import nbformat | |
from nbconvert.preprocessors import ExecutePreprocessor, CellExecutionError | |
fpaths = glob.glob('pcard-submissions/*.ipynb') | |
for fpath in fpaths: | |
print(f'Running {fpath}') | |
nb = nbformat.read(fpath, as_version=4) | |
try: | |
print('=============================') | |
ep = ExecutePreprocessor(timeout=600, kernel_name='python3') | |
ep.preprocess(nb) | |
except CellExecutionError as e: | |
print(f'CellExecutionError on {fpath}') | |
print('-----------------------------') | |
print(e) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment