@@ -51,6 +51,9 @@ def get_args():
5151 parser .add_argument ("--nodelete-failed" ,
5252 help = "do not delete failed results (submission checker will fail)" ,
5353 default = False , action = "store_true" )
54+ parser .add_argument ("--keep-structure" ,
55+ help = "keep folder structure (newer versions of submission checker might fail)" ,
56+ default = False , action = "store_true" )
5457
5558 parser .add_argument (
5659 "--version" ,
@@ -96,7 +99,7 @@ def delete_empty_dirs(src):
9699 return False
97100
98101
99- def copy_submission_dir (src , dst , filter_submitter ):
102+ def copy_submission_dir (src , dst , filter_submitter , keep_structure = True ):
100103 """
101104 Copies the submission tree to output directory for processing
102105 """
@@ -106,10 +109,20 @@ def copy_submission_dir(src, dst, filter_submitter):
106109 for submitter in next (os .walk (os .path .join (src , division )))[1 ]:
107110 if filter_submitter and submitter != filter_submitter :
108111 continue
109- shutil .copytree (
110- os .path .join (src , division , submitter ),
111- os .path .join (dst , division , submitter ),
112- )
112+ if keep_structure :
113+ shutil .copytree (
114+ os .path .join (src , division , submitter ),
115+ os .path .join (dst , division , submitter ),
116+ )
117+ else :
118+ for dir in next (os .walk (os .path .join (src , division , submitter )))[1 ]:
119+ target_dir = "results" if dir in ["compliance" , "measurements" ] else dir
120+ #target_dir = dir
121+ shutil .copytree (
122+ os .path .join (src , division , submitter , dir ),
123+ os .path .join (dst , division , submitter , target_dir ),
124+ dirs_exist_ok = True
125+ )
113126
114127
115128def change_first_directory_to_open (path ):
@@ -247,8 +260,7 @@ def clean_invalid_results(args, log_path, config, system_desc, system_json,
247260
248261 compliance_is_valid = True
249262 if is_closed_or_network :
250- compliance_dir = change_folder_name_in_path (
251- scenario_path , "results" , "compliance" )
263+ compliance_dir = scenario_path
252264 if not checker .check_compliance_dir (
253265 compliance_dir ,
254266 mlperf_model ,
@@ -262,12 +274,10 @@ def clean_invalid_results(args, log_path, config, system_desc, system_json,
262274
263275 is_valid = accuracy_is_valid and perf_is_valid and compliance_is_valid
264276 if not is_valid : # Remove the scenario result
265- scenario_measurements_path = change_folder_name_in_path (
266- scenario_path , "results" , "measurements" )
277+ scenario_measurements_path = scenario_path
267278 if scenario in [
268279 "Offline" , "MultiStream" ] and (not accuracy_is_valid or not perf_is_valid ) or division == "open" : # they can be inferred
269- scenario_compliance_path = change_folder_name_in_path (
270- scenario_path , "results" , "compliance" )
280+ scenario_compliance_path = scenario_path
271281 log .warning (
272282 f"{ scenario } scenario result is invalid for { system_desc } : { model } in { division } division. Accuracy: { accuracy_is_valid } , Performance: { perf_is_valid } . Removing..." )
273283 if os .path .exists (scenario_path ):
@@ -278,10 +288,8 @@ def clean_invalid_results(args, log_path, config, system_desc, system_json,
278288 shutil .rmtree (scenario_compliance_path )
279289 elif division in ["closed" , "network" ]:
280290 model_results_path = os .path .dirname (scenario_path )
281- model_measurements_path = change_folder_name_in_path (
282- model_results_path , "results" , "measurements" )
283- model_compliance_path = change_folder_name_in_path (
284- model_results_path , "results" , "compliance" )
291+ model_measurements_path = model_results_path
292+ model_compliance_path = model_results_path
285293 model_code_path = os .path .join (
286294 change_folder_name_in_path (
287295 log_path , "results" , "code" ), model )
@@ -301,8 +309,7 @@ def clean_invalid_results(args, log_path, config, system_desc, system_json,
301309 f"{ scenario } scenario result is invalid for { system_desc } : { model } in { division } and open divisions. Accuracy: { accuracy_is_valid } , Performance: { perf_is_valid } . Removing it..." )
302310 if os .path .exists (scenario_path ):
303311 shutil .rmtree (scenario_path )
304- scenario_measurements_path = change_folder_name_in_path (
305- scenario_path , "results" , "measurements" )
312+ scenario_measurements_path = scenario_path
306313 if os .path .exists (scenario_measurements_path ):
307314 shutil .rmtree (scenario_measurements_path )
308315 if not os .path .exists (target_results_path ):
@@ -367,9 +374,7 @@ def infer_scenario_results(args, config):
367374 continue
368375
369376 # process results
370- for directory in ["results" , "measurements" ] + \
371- (["compliance" ] if division == "closed" else []):
372-
377+ for directory in ["results" ]:
373378 log_path = os .path .join (division , submitter , directory )
374379 if not os .path .exists (log_path ):
375380 log .error ("no submission in %s" , log_path )
@@ -550,7 +555,7 @@ def main():
550555 log .error (f"output directory { args .output } already exists" )
551556 sys .exit (1 )
552557 os .makedirs (args .output )
553- copy_submission_dir (args .input , args .output , args .submitter )
558+ copy_submission_dir (args .input , args .output , args .submitter , args . keep_structure )
554559 src_dir = args .output
555560
556561 config = checker .Config (
@@ -574,3 +579,6 @@ def main():
574579
575580if __name__ == "__main__" :
576581 sys .exit (main ())
582+
583+ if __name__ == "__main__" :
584+ sys .exit (main ())
0 commit comments