-
Notifications
You must be signed in to change notification settings - Fork 19
/
ipynb_check.py
36 lines (30 loc) · 1.03 KB
/
ipynb_check.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""
Tests notebooks in the given directory
"""
from os import listdir
import subprocess
def list_files(directory, extension):
"""
Returns all files in the given directory and the given extension
"""
return (f for f in listdir(directory) if f.endswith('.' + extension))
def main():
"""
Prints notebooks with the status of the checking
"""
notebooks = list(list_files('./', 'ipynb'))
status = []
for notebook in notebooks:
output = subprocess.run(
['jupyter', 'nbconvert', '--ExecutePreprocessor.timeout=300',
'--to', 'notebook', '--inplace',
'--execute', notebook],
stdout=subprocess.DEVNULL)
if output.returncode == 0:
status.append("passed")
else:
status.append("failed")
for (notebook, stat) in zip(notebooks, status):
print("The build test for " + notebook + " " + stat + ".")
if __name__ == "__main__":
main()