@@ -113,7 +113,7 @@ def get_running_cuda_version() -> str:
113
113
return ""
114
114
115
115
116
- def get_running_torch_version ():
116
+ def get_running_torch_version () -> str :
117
117
"""Extract the version of actual PyTorch for this runtime."""
118
118
try :
119
119
import torch
@@ -322,7 +322,13 @@ def bash_render(folder: str, output_file: str = PATH_SCRIPT_RENDER) -> Optional[
322
322
# dry run does not execute the notebooks just takes them as they are
323
323
cmd .append (f"cp { ipynb_file } { pub_ipynb } " )
324
324
# 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
+ ]
326
332
else :
327
333
pip_req , pip_args = AssistantCLI ._parse_requirements (folder )
328
334
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[
335
341
# Export the actual packages used in runtime
336
342
cmd .append (f"meta_file=$(python .actions/assistant.py update-env-details { folder } )" )
337
343
# 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
+ ]
339
351
# if thumb image is linked to the notebook, copy and version it too
340
352
if thumb_file :
341
353
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[
347
359
fopen .write (os .linesep .join (cmd ))
348
360
349
361
@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 ]:
351
363
"""Prepare bash script for running tests of a particular notebook.
352
364
353
365
Args:
@@ -364,11 +376,12 @@ def bash_test(folder: str, output_file: str = PATH_SCRIPT_TEST) -> Optional[str]
364
376
365
377
# prepare isolated environment with inheriting the global packages
366
378
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
+ ]
372
385
373
386
cmd .append (f"# available: { AssistantCLI .DEVICE_ACCELERATOR } " )
374
387
if AssistantCLI ._valid_accelerator (folder ):
@@ -378,21 +391,30 @@ def bash_test(folder: str, output_file: str = PATH_SCRIPT_TEST) -> Optional[str]
378
391
# Export the actual packages used in runtime
379
392
cmd .append (f"meta_file=$(python .actions/assistant.py update-env-details { folder } --base_path .)" )
380
393
# 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" )
383
402
else :
384
403
pub_ipynb = os .path .join (DIR_NOTEBOOKS , f"{ folder } .ipynb" )
385
404
pub_meta = pub_ipynb .replace (".ipynb" , ".yaml" )
386
405
# copy and add meta config
387
406
cmd += [
388
407
f"mkdir -p { os .path .dirname (pub_meta )} " ,
389
408
f"cp { meta_file } { pub_meta } " ,
409
+ 'echo "#====== START OF YAML FILE ======#"' ,
390
410
f"cat { pub_meta } " ,
411
+ 'echo "#======= END OF YAML FILE =======#"' ,
391
412
f"git add { pub_meta } " ,
392
413
]
393
414
warn ("Invalid notebook's accelerator for this device. So no tests will be run!!!" , RuntimeWarning )
394
415
# 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' )} " ]
396
418
if not output_file :
397
419
return os .linesep .join (cmd )
398
420
with open (output_file , "w" ) as fopen :
@@ -707,7 +729,10 @@ def update_env_details(folder: str, base_path: str = DIR_NOTEBOOKS) -> str:
707
729
708
730
Args:
709
731
folder: path to the folder
710
- base_path:
732
+ base_path: base path with notebooks
733
+
734
+ Returns:
735
+ path the updated YAML file
711
736
712
737
"""
713
738
meta = AssistantCLI ._load_meta (folder )
0 commit comments