@@ -113,7 +113,7 @@ def get_running_cuda_version() -> str:
113113 return ""
114114
115115
116- def get_running_torch_version ():
116+ def get_running_torch_version () -> str :
117117 """Extract the version of actual PyTorch for this runtime."""
118118 try :
119119 import torch
@@ -322,7 +322,13 @@ def bash_render(folder: str, output_file: str = PATH_SCRIPT_RENDER) -> Optional[
322322 # dry run does not execute the notebooks just takes them as they are
323323 cmd .append (f"cp { ipynb_file } { pub_ipynb } " )
324324 # copy and add meta config
325- cmd += [f"cp { meta_file } { pub_meta } " , f"cat { pub_meta } " , f"git add { pub_meta } " ]
325+ cmd += [
326+ f"cp { meta_file } { pub_meta } " ,
327+ 'echo "#====== START OF YAML FILE ======#"' ,
328+ f"cat { pub_meta } " ,
329+ 'echo "#======= END OF YAML FILE =======#"' ,
330+ f"git add { pub_meta } " ,
331+ ]
326332 else :
327333 pip_req , pip_args = AssistantCLI ._parse_requirements (folder )
328334 cmd += [f"pip install { pip_req } --quiet { pip_args } " , "pip list" ]
@@ -335,7 +341,13 @@ def bash_render(folder: str, output_file: str = PATH_SCRIPT_RENDER) -> Optional[
335341 # Export the actual packages used in runtime
336342 cmd .append (f"meta_file=$(python .actions/assistant.py update-env-details { folder } )" )
337343 # copy and add to version the enriched meta config
338- cmd += ["echo $meta_file" , "cat $meta_file" , "git add $meta_file" ]
344+ cmd += [
345+ "echo $meta_file" ,
346+ 'echo "#====== START OF YAML FILE ======#"' ,
347+ "cat $meta_file" ,
348+ 'echo "#======= END OF YAML FILE =======#"' ,
349+ "git add $meta_file" ,
350+ ]
339351 # if thumb image is linked to the notebook, copy and version it too
340352 if thumb_file :
341353 cmd += [f"cp { thumb_file } { pub_thumb } " , f"git add { pub_thumb } " ]
@@ -347,7 +359,7 @@ def bash_render(folder: str, output_file: str = PATH_SCRIPT_RENDER) -> Optional[
347359 fopen .write (os .linesep .join (cmd ))
348360
349361 @staticmethod
350- def bash_test (folder : str , output_file : str = PATH_SCRIPT_TEST ) -> Optional [str ]:
362+ def bash_test (folder : str , output_file : str = PATH_SCRIPT_TEST , virtualenv : bool = False ) -> Optional [str ]:
351363 """Prepare bash script for running tests of a particular notebook.
352364
353365 Args:
@@ -364,11 +376,12 @@ def bash_test(folder: str, output_file: str = PATH_SCRIPT_TEST) -> Optional[str]
364376
365377 # prepare isolated environment with inheriting the global packages
366378 path_venv = os .path .join (folder , "venv" )
367- cmd += [
368- f"python -m virtualenv --system-site-packages { path_venv } " ,
369- f"source { os .path .join (path_venv , 'bin' , 'activate' )} " ,
370- "pip --version" ,
371- ]
379+ if virtualenv :
380+ cmd += [
381+ f"python -m virtualenv --system-site-packages { path_venv } " ,
382+ f"source { os .path .join (path_venv , 'bin' , 'activate' )} " ,
383+ "pip --version" ,
384+ ]
372385
373386 cmd .append (f"# available: { AssistantCLI .DEVICE_ACCELERATOR } " )
374387 if AssistantCLI ._valid_accelerator (folder ):
@@ -378,21 +391,30 @@ def bash_test(folder: str, output_file: str = PATH_SCRIPT_TEST) -> Optional[str]
378391 # Export the actual packages used in runtime
379392 cmd .append (f"meta_file=$(python .actions/assistant.py update-env-details { folder } --base_path .)" )
380393 # show created meta config
381- cmd += ["echo $meta_file" , "cat $meta_file" ]
382- cmd .append (f"python -m pytest { ipynb_file } -v --nbval --nbval-cell-timeout=300" )
394+ cmd += [
395+ "echo $meta_file" ,
396+ 'echo "#====== START OF YAML FILE ======#"' ,
397+ "cat $meta_file" ,
398+ 'echo "#======= END OF YAML FILE =======#"' ,
399+ ]
400+ # use standard jupyter's executable via CMD
401+ cmd .append (f"jupyter execute { ipynb_file } --inplace" )
383402 else :
384403 pub_ipynb = os .path .join (DIR_NOTEBOOKS , f"{ folder } .ipynb" )
385404 pub_meta = pub_ipynb .replace (".ipynb" , ".yaml" )
386405 # copy and add meta config
387406 cmd += [
388407 f"mkdir -p { os .path .dirname (pub_meta )} " ,
389408 f"cp { meta_file } { pub_meta } " ,
409+ 'echo "#====== START OF YAML FILE ======#"' ,
390410 f"cat { pub_meta } " ,
411+ 'echo "#======= END OF YAML FILE =======#"' ,
391412 f"git add { pub_meta } " ,
392413 ]
393414 warn ("Invalid notebook's accelerator for this device. So no tests will be run!!!" , RuntimeWarning )
394415 # deactivate and clean local environment
395- cmd += ["deactivate" , f"rm -rf { os .path .join (folder , 'venv' )} " ]
416+ if virtualenv :
417+ cmd += ["deactivate" , f"rm -rf { os .path .join (folder , 'venv' )} " ]
396418 if not output_file :
397419 return os .linesep .join (cmd )
398420 with open (output_file , "w" ) as fopen :
@@ -707,7 +729,10 @@ def update_env_details(folder: str, base_path: str = DIR_NOTEBOOKS) -> str:
707729
708730 Args:
709731 folder: path to the folder
710- base_path:
732+ base_path: base path with notebooks
733+
734+ Returns:
735+ path the updated YAML file
711736
712737 """
713738 meta = AssistantCLI ._load_meta (folder )
0 commit comments