@@ -16,34 +16,16 @@ def should_skip(notebook_path: str, skip_list: List[str]) -> bool:
16
16
17
17
18
18
def run_notebook (notebook_path : str , root : str ) -> Tuple [bool , Optional [str ]]:
19
- """Execute a single notebook and print outputs of each cell ."""
19
+ """Execute a single notebook."""
20
20
try :
21
21
print (f"🔧 running: { notebook_path } " )
22
22
with open (notebook_path , encoding = "utf-8" ) as f :
23
23
nb = nbformat .read (f , as_version = 4 )
24
24
25
- ep = ExecutePreprocessor (timeout = SINGLE_NOTEBOOK_TIMEOUT , kernel_name = "python3" )
25
+ ep = ExecutePreprocessor (
26
+ timeout = SINGLE_NOTEBOOK_TIMEOUT ,
27
+ kernel_name = "python3" )
26
28
ep .preprocess (nb , {"metadata" : {"path" : root }})
27
-
28
- # Print outputs of each cell
29
- for i , cell in enumerate (nb .cells ):
30
- if cell .cell_type == 'code' :
31
- print (f"\n 📦 Cell { i + 1 } :\n { cell .source .strip ()} " )
32
- for output in cell .get ('outputs' , []):
33
- if output .output_type == 'stream' :
34
- print (output .text )
35
- elif output .output_type == 'error' :
36
- print ("❌ Error:" )
37
- print ("\n " .join (output .get ('traceback' , [])))
38
- elif output .output_type == 'execute_result' :
39
- data = output .get ('data' , {})
40
- if 'text/plain' in data :
41
- print (data ['text/plain' ])
42
- elif output .output_type == 'display_data' :
43
- data = output .get ('data' , {})
44
- if 'text/plain' in data :
45
- print (data ['text/plain' ])
46
-
47
29
return True , None
48
30
except Exception as e :
49
31
return False , str (e )
0 commit comments