1414from typing import Optional
1515
1616import numpy as np
17-
1817from labml import lab , monit
1918from labml import logger
2019from labml .internal .util import rm_tree
@@ -59,12 +58,10 @@ def _collect_python_files(path: Path):
5958
6059 _collect_python_files (source_path )
6160
62- logger .inspect ([f .path for f in files ])
63-
6461 return files
6562
6663
67- def _read_file (path : Path ) -> str :
64+ def read_file (path : Path ) -> str :
6865 """
6966 Read a file
7067 """
@@ -76,11 +73,11 @@ def _read_file(path: Path) -> str:
7673 return content
7774
7875
79- def _load_code (path : PurePath , source_files : List [PythonFile ]):
76+ def concat_and_save (path : PurePath , source_files : List [PythonFile ]):
8077 with open (str (path ), 'w' ) as f :
8178 for i , source in monit .enum (f"Write { path .name } " , source_files ):
8279 f .write (f"# PROJECT: { source .project } FILE: { str (source .relative_path )} \n " )
83- f .write (_read_file (source .path ) + "\n " )
80+ f .write (read_file (source .path ) + "\n " )
8481
8582
8683def get_repos_from_readme (filename : str ):
@@ -227,8 +224,8 @@ def main():
227224 logger .inspect (source_files )
228225
229226 train_valid_split = int (len (source_files ) * 0.9 )
230- _load_code (lab .get_data_path () / 'train.py' , source_files [:train_valid_split ])
231- _load_code (lab .get_data_path () / 'valid.py' , source_files [train_valid_split :])
227+ concat_and_save (lab .get_data_path () / 'train.py' , source_files [:train_valid_split ])
228+ concat_and_save (lab .get_data_path () / 'valid.py' , source_files [train_valid_split :])
232229
233230
234231if __name__ == '__main__' :
0 commit comments