9def copy_files(input_path, output_path, training_data=False):
11 Copy specific files from the input training collection to a new collection used for FEI rebasing
14 input_path (str): Path to the source directory containing the files to copy.
15 output_path (str): Path to the destination directory where selected files will be copied.
16 training_data (bool): If True, copy training data files.
18 if os.path.exists(output_path):
19 shutil.rmtree(output_path)
20 os.makedirs(output_path)
21 os.makedirs(os.path.join(output_path,
'collection'))
25 os.path.join(input_path,
'collection',
'localdb'),
26 os.path.join(output_path,
'collection',
'localdb'))
30 os.path.join(input_path,
'collection',
'Summary.pickle'),
31 os.path.join(output_path,
'collection',
'Summary.pickle.backup_previous'))
34 xml_files = glob.glob(os.path.join(input_path,
'collection',
'*.xml'))
35 for xml_file
in xml_files:
36 if not fei.core.Teacher.check_if_weightfile_is_fake(xml_file):
37 shutil.copy(xml_file, os.path.join(output_path,
'collection'))
38 shutil.copy(xml_file.replace(
'.xml',
'.log'), os.path.join(output_path,
'collection'))
42 os.path.join(input_path,
'collection',
'Monitor_TrainingData.root'),
43 os.path.join(output_path,
'collection',
'Monitor_TrainingData.root'))
45 os.path.join(input_path,
'collection',
'Monitor_ModuleStatistics.root'),
46 os.path.join(output_path,
'collection',
'Monitor_ModuleStatistics.root'))
50 os.path.join(input_path,
'collection',
'training_input.root'),
51 os.path.join(output_path,
'collection',
'training_input.root'))
53 os.path.join(input_path,
'collection',
'validation_input.root'),
54 os.path.join(output_path,
'collection',
'validation_input.root'))
58if __name__ ==
"__main__":
60 parser = argparse.ArgumentParser(description=
'Copy files for re-basing FEI examples.')
61 parser.add_argument(
'-i',
'--input_path', type=str, required=
True,
62 help=
'Path to the source directory containing the files to copy.')
63 parser.add_argument(
'-o',
'--output_path', type=str, required=
True,
64 help=
'Path to the destination directory where selected files will be copied.')
65 parser.add_argument(
'-t',
'--training_data', action=
'store_true', help=
'Copy training data files.')
67 args = parser.parse_args()
68 copy_files(args.input_path, args.output_path, args.training_data)