2222COLAB_REPO_LINK = "https://colab.research.google.com/github/PytorchLightning"
2323BRANCH_DEFAULT = "main"
2424BRANCH_PUBLISHED = "publication"
25+ DIR_NOTEBOOKS = ".notebooks"
2526URL_PL_DOWNLOAD = f"https://github.com/PyTorchLightning/{ REPO_NAME } /raw/{ BRANCH_DEFAULT } "
2627TEMPLATE_HEADER = f"""# %%%% [markdown]
2728#
3435# %(description)s
3536#
3637# ---
37- # Open in [{{height="20px" width="117px"}}]({ COLAB_REPO_LINK } /{ REPO_NAME } /blob/{ BRANCH_PUBLISHED } /.notebooks /%(local_ipynb)s)
38+ # Open in [{{height="20px" width="117px"}}]({ COLAB_REPO_LINK } /{ REPO_NAME } /blob/{ BRANCH_PUBLISHED } /{ DIR_NOTEBOOKS } /%(local_ipynb)s)
3839#
3940# Give us a ⭐ [on Github](https://www.github.com/PytorchLightning/pytorch-lightning/)
4041# | Check out [the documentation](https://pytorch-lightning.readthedocs.io/en/latest/)
@@ -131,7 +132,6 @@ class AssistantCLI:
131132
132133 DEVICE_ACCELERATOR = os .environ .get ("ACCELERATOR" , "cpu" ).lower ()
133134 DRY_RUN = bool (int (os .environ .get ("DRY_RUN" , 0 )))
134- _DIR_NOTEBOOKS = ".notebooks"
135135 _META_REQUIRED_FIELDS = ("title" , "author" , "license" , "description" )
136136 _SKIP_DIRS = (
137137 ".actions" ,
@@ -141,7 +141,7 @@ class AssistantCLI:
141141 "docs" ,
142142 "_TEMP" ,
143143 "requirements" ,
144- _DIR_NOTEBOOKS ,
144+ DIR_NOTEBOOKS ,
145145 )
146146 _META_FILE_REGEX = ".meta.{yaml,yml}"
147147 _META_PIP_KEY = "pip__"
@@ -236,11 +236,11 @@ def bash_render(folder: str) -> str:
236236 print (f"Rendering: { folder } \n " )
237237 cmd = list (AssistantCLI ._BASH_SCRIPT_BASE )
238238 ipynb_file , meta_file , thumb_file = AssistantCLI ._valid_folder (folder , ext = ".ipynb" )
239- pub_ipynb = os .path .join (AssistantCLI . _DIR_NOTEBOOKS , f"{ folder } .ipynb" )
239+ pub_ipynb = os .path .join (DIR_NOTEBOOKS , f"{ folder } .ipynb" )
240240 pub_dir = os .path .dirname (pub_ipynb )
241- pub_meta = os .path .join (AssistantCLI . _DIR_NOTEBOOKS , f"{ folder } .yaml" )
241+ pub_meta = os .path .join (DIR_NOTEBOOKS , f"{ folder } .yaml" )
242242 thumb_ext = os .path .splitext (thumb_file )[- 1 ] if thumb_file else "."
243- pub_thumb = os .path .join (AssistantCLI . _DIR_NOTEBOOKS , f"{ folder } { thumb_ext } " ) if thumb_file else ""
243+ pub_thumb = os .path .join (DIR_NOTEBOOKS , f"{ folder } { thumb_ext } " ) if thumb_file else ""
244244 cmd .append (f"mkdir -p { pub_dir } " )
245245 pip_req , pip_args = AssistantCLI ._parse_requirements (folder )
246246 cmd += [f"pip install { pip_req } { pip_args } " , "pip list" ]
@@ -353,7 +353,7 @@ def _replace_images(lines: list, local_dir: str) -> list:
353353
354354 @staticmethod
355355 def _is_ipynb_parent_dir (dir_path : str ) -> bool :
356- if AssistantCLI ._load_meta (dir_path ):
356+ if AssistantCLI ._find_meta (dir_path ):
357357 return True
358358 sub_dirs = [d for d in glob .glob (os .path .join (dir_path , "*" )) if os .path .isdir (d )]
359359 return any (AssistantCLI ._is_ipynb_parent_dir (d ) for d in sub_dirs )
@@ -473,7 +473,7 @@ def _resolve_path_thumb(path_ipynb: str, path_meta: str) -> Optional[str]:
473473 assert len (paths ) == 1 , f"Found multiple possible thumbnail paths for notebook: { path_ipynb } ."
474474 path_thumb = paths [0 ]
475475 path_thumb = path_thumb .split (os .path .sep )
476- path_thumb = os .path .sep .join (path_thumb [path_thumb .index (AssistantCLI . _DIR_NOTEBOOKS ) + 1 :])
476+ path_thumb = os .path .sep .join (path_thumb [path_thumb .index (DIR_NOTEBOOKS ) + 1 :])
477477 return path_thumb
478478
479479 @staticmethod
@@ -495,13 +495,13 @@ def copy_notebooks(
495495 """
496496 ls_ipynb = []
497497 for sub in patterns :
498- ls_ipynb += glob .glob (os .path .join (path_root , AssistantCLI . _DIR_NOTEBOOKS , sub , "*.ipynb" ))
498+ ls_ipynb += glob .glob (os .path .join (path_root , DIR_NOTEBOOKS , sub , "*.ipynb" ))
499499
500500 os .makedirs (os .path .join (docs_root , path_docs_ipynb ), exist_ok = True )
501501 ipynb_content = []
502502 for path_ipynb in tqdm .tqdm (ls_ipynb ):
503503 ipynb = path_ipynb .split (os .path .sep )
504- sub_ipynb = os .path .sep .join (ipynb [ipynb .index (AssistantCLI . _DIR_NOTEBOOKS ) + 1 :])
504+ sub_ipynb = os .path .sep .join (ipynb [ipynb .index (DIR_NOTEBOOKS ) + 1 :])
505505 new_ipynb = os .path .join (docs_root , path_docs_ipynb , sub_ipynb )
506506 os .makedirs (os .path .dirname (new_ipynb ), exist_ok = True )
507507
@@ -510,7 +510,7 @@ def copy_notebooks(
510510
511511 if path_thumb is not None :
512512 new_thumb = os .path .join (docs_root , path_docs_images , path_thumb )
513- old_path_thumb = os .path .join (path_root , AssistantCLI . _DIR_NOTEBOOKS , path_thumb )
513+ old_path_thumb = os .path .join (path_root , DIR_NOTEBOOKS , path_thumb )
514514 os .makedirs (os .path .dirname (new_thumb ), exist_ok = True )
515515 copyfile (old_path_thumb , new_thumb )
516516 path_thumb = os .path .join (path_docs_images , path_thumb )
@@ -552,7 +552,7 @@ def _parse(pkg: str, keys: str = " <=>[]") -> str:
552552 meta ["environment" ] = [env [r ] for r in require ]
553553 meta ["published" ] = datetime .now ().isoformat ()
554554
555- fmeta = os .path .join (AssistantCLI . _DIR_NOTEBOOKS , dir_path ) + ".yaml"
555+ fmeta = os .path .join (DIR_NOTEBOOKS , dir_path ) + ".yaml"
556556 yaml .safe_dump (meta , stream = open (fmeta , "w" ), sort_keys = False )
557557
558558
0 commit comments