File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -30,10 +30,21 @@ def test_notebook_execution(notebook_path):
3030
3131 # Check if metadata is updated correctly
3232 print ("Injected Metadata:" , nb .metadata .get ('parameters' ))
33-
33+
34+ exec_globals = {}
3435 for idx , cell in enumerate (nb .cells ):
35- print (f"Cell { idx } Type: { cell ['cell_type' ]} " )
36- print (cell ['source' ][:100 ]) # Print the first 100 characters of the cell source
36+ if cell .cell_type == "code" :
37+ print (f"Executing Cell { idx } :" )
38+ print (cell ['source' ][:100 ]) # Print the first 100 characters of the cell source
39+ try :
40+ exec (cell .source , exec_globals )
41+ except Exception as e :
42+ print (f"Error in Cell { idx } : { e } " )
43+
44+
45+ #for idx, cell in enumerate(nb.cells):
46+ # print(f"Cell {idx} Type: {cell['cell_type']}")
47+ # print(cell['source'][:100]) # Print the first 100 characters of the cell source
3748
3849 #ep = ExecutePreprocessor(timeout=600, kernel_name='python3')
3950 #ep.preprocess(nb, {'metadata': {'path': './'}})
You can’t perform that action at this time.
0 commit comments