execute_all_notebooks.py 706 B

1234567891011121314151617181920
  1. """A helper script to execute all of the notebooks
  2. in your /notebooks folder. This is helpful if you wish
  3. to ensure that all of your notebooks run, and that the output
  4. contained in the notebook files is up-to-date."""
  5. from glob import glob
  6. from subprocess import check_call
  7. from tqdm import tqdm
  8. ipynb_files = glob('./notebooks/**/*.ipynb', recursive=True)
  9. failed_files = []
  10. for ifile in tqdm(ipynb_files):
  11. call = 'jupyter nbconvert --inplace --ExecutePreprocessor.kernel_name=python3 --to notebook --execute {}'.format(ifile)
  12. try:
  13. out = check_call(call.split())
  14. except Exception:
  15. failed_files.append(ifile)
  16. print('Failing files:')
  17. for ifile in failed_files:
  18. print(ifile)