11import argparse
22import copy
3- import multiprocess
43import os
54import shutil
65import string
98from functools import partial
109from pathlib import Path
1110
11+ import multiprocess
1212import nbformat
1313from nbconvert .preprocessors import ExecutePreprocessor
1414
2020TRANS_TABLE = str .maketrans (dict .fromkeys (string .whitespace ))
2121
2222
23- def inject_sst ():
23+ def inject_shared_download ():
2424 delim = "&" if os .name == "nt" else ";"
2525 subprocess .call (
2626 delim .join ([INSTALL_SOURCE_VERSION_COMMAND [4 :], INSTALL_SST_COMMAND ]),
@@ -108,7 +108,7 @@ def check_notebook_output(notebook_path, env="python3", ignore_whitespace=False)
108108 new_cell_stdout_ = new_cell_stdout
109109
110110 if ignore_whitespace :
111- original_cell = original_cell_stdout .translate (TRANS_TABLE )
111+ original_cell_stdout = original_cell_stdout .translate (TRANS_TABLE )
112112 new_cell_stdout = new_cell_stdout .translate (TRANS_TABLE )
113113 else :
114114 if new_cell_stdout [- 1 ] == "\n " and original_cell_stdout [- 1 ] != "\n " :
@@ -150,8 +150,8 @@ def check_notebook_output(notebook_path, env="python3", ignore_whitespace=False)
150150 report = check_notebook_output (notebook_path , env = args .env , ignore_whitespace = args .ignore_whitespace )
151151 reports .append (report )
152152 else :
153- # inject the SST dataset to prevent parallel download
154- inject_sst ()
153+ # predownload datasets/vectorizers to prevent parallel download
154+ inject_shared_download ()
155155 with multiprocess .Pool (num_proc ) as pool :
156156 reports = pool .map (partial (check_notebook_output , env = args .env , ignore_whitespace = args .ignore_whitespace ), notebook_paths )
157157
@@ -168,7 +168,7 @@ def check_notebook_output(notebook_path, env="python3", ignore_whitespace=False)
168168 for i , original_output , new_output in report ),
169169 " " * 4 ,
170170 )
171- for notebook , report in reports
171+ for notebook , report in reports if len ( report ) > 0
172172 ])
173173 raise Exception (
174174 "❌❌ Mismatches found in the outputs of the notebooks:\n \n " + reports_str
0 commit comments