Skip to content

Commit

Permalink
Ensure notebooks are cleaned in PRs
Browse files Browse the repository at this point in the history
Fixes #436
  • Loading branch information
u8sand committed Nov 23, 2020
1 parent 6fe886f commit ec4d0d7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions validate/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
click
git+git://github.com/Maayanlab/appyter.git
jsonschema
nbformat
Pillow
11 changes: 11 additions & 0 deletions validate/validate_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import sys
import json
import click
import nbformat as nbf
import traceback
import jsonschema
import urllib.request, urllib.error
Expand Down Expand Up @@ -79,6 +80,16 @@ def validate_appyter(appyter):
#
nbfile = config['appyter']['file']
#
print(f"{appyter}: Checking notebook for issues..")
nb = nbf.read(open(nbfile, 'r'), as_version=4)
for cell in nb.cells:
if cell['cell_type'] == 'code':
assert not cell.get('execution_count'), "Please clear all notebook output & metadata"
assert not cell.get('metadata'), "Please clear all notebook output & metadata"
assert not cell.get('outputs'), "Please clear all notebook output & metadata"
assert not nb['metadata'].get('widgets'), "Please clear all notebook output & metadata"
assert not nb['metadata'].get('execution_info'), "Please clear all notebook output & metadata"
#
print(f"{appyter}: Preparing docker to run `{nbfile}`...")
assert os.path.isfile(os.path.join('appyters', appyter, nbfile)), f"Missing appyters/{appyter}/{nbfile}"
try:
Expand Down

0 comments on commit ec4d0d7

Please sign in to comment.