@@ -328,7 +328,7 @@ def bash_render(folder: str) -> str:
328328 cmd .append (f"python .actions/assistant.py update-env-details { folder } " )
329329 # copy and add to version the enriched meta config
330330 cmd += [f"cp { meta_file } { pub_meta } " , f"git add { pub_meta } " ]
331- # if thumb image is linked to to the notebook, copy and version it too
331+ # if thumb image is linked to the notebook, copy and version it too
332332 if thumb_file :
333333 cmd += [f"cp { thumb_file } { pub_thumb } " , f"git add { pub_thumb } " ]
334334 # add the generated notebook to version
@@ -361,7 +361,7 @@ def bash_test(folder: str) -> str:
361361
362362 cmd .append (f"# available: { AssistantCLI .DEVICE_ACCELERATOR } " )
363363 if AssistantCLI ._valid_accelerator (folder ):
364- cmd .append (f"python -m pytest { ipynb_file } -v --nbval" )
364+ cmd .append (f"python -m pytest { ipynb_file } -v --nbval --nbval-cell-timeout=300 " )
365365 else :
366366 warn ("Invalid notebook's accelerator for this device. So no tests will be run!!!" , RuntimeWarning )
367367 # deactivate and clean local environment
@@ -443,7 +443,7 @@ def group_folders(
443443 fpath_gitdiff : str ,
444444 fpath_change_folders : str = "changed-folders.txt" ,
445445 fpath_drop_folders : str = "dropped-folders.txt" ,
446- fpaths_actual_dirs : Sequence [str ] = tuple (),
446+ fpath_actual_dirs : Sequence [str ] = tuple (),
447447 strict : bool = True ,
448448 root_path : str = "" ,
449449 ) -> None :
@@ -458,23 +458,23 @@ def group_folders(
458458
459459 fpath_change_folders: output file with changed folders
460460 fpath_drop_folders: output file with deleted folders
461- fpaths_actual_dirs : files with listed all folder in particular stat
461+ fpath_actual_dirs : files with listed all folder in particular stat
462462 strict: raise error if some folder outside skipped does not have valid meta file
463463 root_path: path to the root tobe added for all local folder paths in files
464464
465465 Example:
466- >> python assistant.py group-folders ../target-diff.txt --fpaths_actual_dirs "['../dirs-main.txt', '../dirs-publication.txt']"
466+ >> python assistant.py group-folders ../target-diff.txt --fpath_actual_dirs "['../dirs-main.txt', '../dirs-publication.txt']"
467467 """
468468 with open (fpath_gitdiff ) as fp :
469469 changed = [ln .strip () for ln in fp .readlines ()]
470470 dirs = [os .path .dirname (ln ) for ln in changed ]
471471 # not empty paths
472472 dirs = [ln for ln in dirs if ln ]
473473
474- if fpaths_actual_dirs :
475- assert isinstance (fpaths_actual_dirs , list )
476- assert all (os .path .isfile (p ) for p in fpaths_actual_dirs )
477- dir_sets = [{ln .strip () for ln in open (fp ).readlines ()} for fp in fpaths_actual_dirs ]
474+ if fpath_actual_dirs :
475+ assert isinstance (fpath_actual_dirs , list )
476+ assert all (os .path .isfile (p ) for p in fpath_actual_dirs )
477+ dir_sets = [{ln .strip () for ln in open (fp ).readlines ()} for fp in fpath_actual_dirs ]
478478 # get only different
479479 dirs += list (set .union (* dir_sets ) - set .intersection (* dir_sets ))
480480
@@ -564,7 +564,7 @@ def copy_notebooks(
564564 path_docs_ipynb : str = "notebooks" ,
565565 path_docs_images : str = "_static/images" ,
566566 patterns : Sequence [str ] = ("." , "**" ),
567- ):
567+ ) -> None :
568568 """Copy all notebooks from a folder to doc folder.
569569
570570 Args:
@@ -609,13 +609,13 @@ def copy_notebooks(
609609 ipynb_content .append (os .path .join ("notebooks" , sub_ipynb ))
610610
611611 @staticmethod
612- def update_env_details (dir_path : str ):
612+ def update_env_details (folder : str ) -> None :
613613 """Export the actual packages used in runtime.
614614
615615 Args:
616- dir_path : path to the folder
616+ folder : path to the folder
617617 """
618- meta = AssistantCLI ._load_meta (dir_path )
618+ meta = AssistantCLI ._load_meta (folder )
619619 # default is COU runtime
620620 with open (PATH_REQ_DEFAULT ) as fp :
621621 req = fp .readlines ()
@@ -636,9 +636,16 @@ def _parse_package_name(pkg: str, keys: str = " <=>[]@", egg_name: str = "#egg="
636636 meta ["environment" ] = [env [r ] for r in require ]
637637 meta ["published" ] = datetime .now ().isoformat ()
638638
639- fmeta = os .path .join (DIR_NOTEBOOKS , dir_path ) + ".yaml"
639+ fmeta = os .path .join (DIR_NOTEBOOKS , folder ) + ".yaml"
640640 yaml .safe_dump (meta , stream = open (fmeta , "w" ), sort_keys = False )
641641
642+ @staticmethod
643+ def list_dirs (folder : str = ".notebooks" ) -> str :
644+ """List all sub-folders in a given tree including any ipynb."""
645+ ipynbs = glob .glob (os .path .join (folder , "*.ipynb" )) + glob .glob (os .path .join (folder , "**" , "*.ipynb" ))
646+ ipynbs = sorted (os .path .splitext (os .path .sep .join (p .split (os .path .sep )[1 :]))[0 ] for p in ipynbs )
647+ return os .linesep .join (ipynbs )
648+
642649
643650if __name__ == "__main__" :
644651 fire .Fire (AssistantCLI )
0 commit comments