@@ -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,26 @@ 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  object  in  os .listdir (os .path .join (src , division , submitter )):
119+                     if  os .path .isfile (os .path .join (src , division , submitter , object )):
120+                         shutil .copyfile (
121+                             os .path .join (src , division , submitter , object ),
122+                             os .path .join (dst , division , submitter , object ),
123+                             dirs_exist_ok  =  True 
124+                         )
125+                     elif  os .path .isdir (os .path .join (src , division , submitter , object )):
126+                         target_dir  =  "results"  if  object  in  ["compliance" , "measurements" ] else  object 
127+                         shutil .copytree (
128+                             os .path .join (src , division , submitter , object ),
129+                             os .path .join (dst , division , submitter , target_dir ),
130+                             dirs_exist_ok  =  True 
131+                         )
113132
114133
115134def  change_first_directory_to_open (path ):
@@ -247,8 +266,7 @@ def clean_invalid_results(args, log_path, config, system_desc, system_json,
247266
248267            compliance_is_valid  =  True 
249268            if  is_closed_or_network :
250-                 compliance_dir  =  change_folder_name_in_path (
251-                     scenario_path , "results" , "compliance" )
269+                 compliance_dir  =  scenario_path 
252270                if  not  checker .check_compliance_dir (
253271                    compliance_dir ,
254272                    mlperf_model ,
@@ -262,12 +280,10 @@ def clean_invalid_results(args, log_path, config, system_desc, system_json,
262280
263281        is_valid  =  accuracy_is_valid  and  perf_is_valid  and  compliance_is_valid 
264282        if  not  is_valid :  # Remove the scenario result 
265-             scenario_measurements_path  =  change_folder_name_in_path (
266-                 scenario_path , "results" , "measurements" )
283+             scenario_measurements_path  =  scenario_path 
267284            if  scenario  in  [
268285                    "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" )
286+                 scenario_compliance_path  =  scenario_path 
271287                log .warning (
272288                    f"{ scenario } { system_desc } { model } { division } { accuracy_is_valid } { perf_is_valid }  )
273289                if  os .path .exists (scenario_path ):
@@ -278,10 +294,8 @@ def clean_invalid_results(args, log_path, config, system_desc, system_json,
278294                    shutil .rmtree (scenario_compliance_path )
279295            elif  division  in  ["closed" , "network" ]:
280296                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" )
297+                 model_measurements_path  =  model_results_path 
298+                 model_compliance_path  =  model_results_path 
285299                model_code_path  =  os .path .join (
286300                    change_folder_name_in_path (
287301                        log_path , "results" , "code" ), model )
@@ -301,8 +315,7 @@ def clean_invalid_results(args, log_path, config, system_desc, system_json,
301315                            f"{ scenario } { system_desc } { model } { division } { accuracy_is_valid } { perf_is_valid }  )
302316                        if  os .path .exists (scenario_path ):
303317                            shutil .rmtree (scenario_path )
304-                         scenario_measurements_path  =  change_folder_name_in_path (
305-                             scenario_path , "results" , "measurements" )
318+                         scenario_measurements_path  =  scenario_path 
306319                        if  os .path .exists (scenario_measurements_path ):
307320                            shutil .rmtree (scenario_measurements_path )
308321                    if  not  os .path .exists (target_results_path ):
@@ -367,9 +380,7 @@ def infer_scenario_results(args, config):
367380                continue 
368381
369382            # process results 
370-             for  directory  in  ["results" , "measurements" ] +  \
371-                     (["compliance" ] if  division  ==  "closed"  else  []):
372- 
383+             for  directory  in  ["results" ]:
373384                log_path  =  os .path .join (division , submitter , directory )
374385                if  not  os .path .exists (log_path ):
375386                    log .error ("no submission in %s" , log_path )
@@ -550,7 +561,7 @@ def main():
550561        log .error (f"output directory { args .output }  )
551562        sys .exit (1 )
552563    os .makedirs (args .output )
553-     copy_submission_dir (args .input , args .output , args .submitter )
564+     copy_submission_dir (args .input , args .output , args .submitter ,  args . keep_structure )
554565    src_dir  =  args .output 
555566
556567    config  =  checker .Config (
@@ -574,3 +585,6 @@ def main():
574585
575586if  __name__  ==  "__main__" :
576587    sys .exit (main ())
588+ 
589+ if  __name__  ==  "__main__" :
590+     sys .exit (main ())
0 commit comments