-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcheck_solutions.py
42 lines (34 loc) · 1.24 KB
/
check_solutions.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
37
38
39
40
41
42
import nbformat
from nbconvert.preprocessors import ExecutePreprocessor
import os
def execute_notebook(notebook_path, cwd):
# Load the notebook
with open(notebook_path) as f:
nb = nbformat.read(f, as_version=4)
# Create a preprocessor
executor = ExecutePreprocessor(timeout=None)
# Execute the notebook
try:
executor.preprocess(nb, {'metadata': {'path': cwd}})
except Exception as e:
# If there is any error, print it
print(f"Error executing notebook {notebook_path}: {e}")
return False
else:
print(f"Notebook {notebook_path} executed successfully.")
return True
notebook_paths = [
'solutions/tensor_introduction/tensor_introduction.ipynb',
'solutions/machine_learning/machine_learning.ipynb',
'solutions/attention/attention.ipynb',
'solutions/feature_extraction/feature_extraction.ipynb',
'solutions/evoformer/evoformer.ipynb',
'solutions/feature_embedding/feature_embedding.ipynb',
'solutions/geometry/geometry.ipynb',
'solutions/structure_module/structure_module.ipynb',
'solutions/model/model.ipynb',
]
for path in notebook_paths:
name = path.split('/')[0]
if not execute_notebook(path, 'solutions'):
break