Skip to content

Commit

Permalink
Exit on first failed notebook, return error codes
Browse files Browse the repository at this point in the history
  • Loading branch information
frankharkins committed Aug 27, 2020
1 parent 6a52d5a commit f948dfc
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions scripts/run_notebooks_soft.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,9 @@ def run_notebook(filename):
ep.preprocess(nb, {'metadata': {'path': './'}})
except Exception as e:
print("[" + datetime.now().time().strftime('%H:%M') + "] " + "Error in file '", filename, "': ", str(e).split('\n')[-2])
execution_failed = True

if not execution_failed:
return 1
return 0


if __name__ == '__main__':
import os
import sys
Expand All @@ -68,10 +64,10 @@ def run_notebook(filename):
filepath = os.path.join(dirpath, name)
print("[" + datetime.now().time().strftime('%H:%M') + "] " + filepath)
total_files += 1
if run_notebook(filepath) == 1:
working_files += 1
if run_notebook(filepath) is not 0:
sys.exit(os.EX_SOFTWARE)
t1 = time.time()
running_time = t1-t0

print("Finished in %.2f seconds" % running_time)
print("%i notebooks were read, %i encountered errors." % (total_files, total_files - working_files))
sys.exit(os.EX_OK)

0 comments on commit f948dfc

Please sign in to comment.