@@ -58,7 +58,7 @@ def update_group_status(group_status, new_status):
5858 return group_status
5959
6060
61- def print_view (term_width , term_height , program_groups_scores , all_results , print_data : PrintData , names , executions ,
61+ def print_view (term_width , term_height , task_id , program_groups_scores , all_results , print_data : PrintData , names , executions ,
6262 groups , scores , tests , possible_score , cpus , hide_memory , config , contest , args ):
6363 width = term_width - 13 # First column has 6 characters, the " | " separator has 3 characters and 4 for margin
6464 programs_in_row = width // 13 # Each program has 10 characters and the " | " separator has 3 characters
@@ -79,7 +79,7 @@ def print_view(term_width, term_height, program_groups_scores, all_results, prin
7979 for solution in names :
8080 lang = package_util .get_file_lang (solution )
8181 for test in tests :
82- time_sum += package_util .get_time_limit (test , config , lang , args )
82+ time_sum += package_util .get_time_limit (test , config , lang , task_id , args )
8383
8484 time_remaining = (len (executions ) - print_data .i - 1 ) * 2 * time_sum / cpus / 1000.0
8585 title = 'Done %4d/%4d. Time remaining (in the worst case): %5d seconds.' \
@@ -122,17 +122,17 @@ def print_table_end():
122122 if results [test ].Time is not None :
123123 if program_times [program ][0 ] < results [test ].Time :
124124 program_times [program ] = (results [test ].Time , package_util .get_time_limit (test , config ,
125- lang , args ))
125+ lang , task_id , args ))
126126 elif status == Status .TL :
127- program_times [program ] = (2 * package_util .get_time_limit (test , config , lang , args ),
128- package_util .get_time_limit (test , config , lang , args ))
127+ program_times [program ] = (2 * package_util .get_time_limit (test , config , lang , task_id , args ),
128+ package_util .get_time_limit (test , config , lang , task_id , args ))
129129 if results [test ].Memory is not None :
130130 if program_memory [program ][0 ] < results [test ].Memory :
131131 program_memory [program ] = (results [test ].Memory , package_util .get_memory_limit (test , config ,
132- lang , args ))
132+ lang , task_id , args ))
133133 elif status == Status .ML :
134- program_memory [program ] = (2 * package_util .get_memory_limit (test , config , lang , args ),
135- package_util .get_memory_limit (test , config , lang , args ))
134+ program_memory [program ] = (2 * package_util .get_memory_limit (test , config , lang , task_id , args ),
135+ package_util .get_memory_limit (test , config , lang , task_id , args ))
136136 if status == Status .PENDING :
137137 group_status = Status .PENDING
138138 else :
@@ -187,29 +187,29 @@ def print_group_seperator():
187187
188188 last_group = None
189189 for test in tests :
190- group = package_util .get_group (test )
190+ group = package_util .get_group (test , task_id )
191191 if last_group != group :
192192 if last_group is not None :
193193 print_group_seperator ()
194194 last_group = group
195195
196- print (margin + "%6s" % package_util .extract_test_id (test ), end = " | " )
196+ print (margin + "%6s" % package_util .extract_test_id (test , task_id ), end = " | " )
197197 for program in program_group :
198198 lang = package_util .get_file_lang (program )
199- result = all_results [program ][package_util .get_group (test )][test ]
199+ result = all_results [program ][package_util .get_group (test , task_id )][test ]
200200 status = result .Status
201201 if status == Status .PENDING : print (10 * ' ' , end = " | " )
202202 else :
203203 print ("%3s" % colorize_status (status ),
204- ("%17s" % color_time (result .Time , package_util .get_time_limit (test , config , lang , args )))
204+ ("%17s" % color_time (result .Time , package_util .get_time_limit (test , config , lang , task_id , args )))
205205 if result .Time is not None else 7 * " " , end = " | " )
206206 print ()
207207 if not hide_memory :
208208 print (8 * " " , end = " | " )
209209 for program in program_group :
210210 lang = package_util .get_file_lang (program )
211- result = all_results [program ][package_util .get_group (test )][test ]
212- print (("%20s" % color_memory (result .Memory , package_util .get_memory_limit (test , config , lang , args )))
211+ result = all_results [program ][package_util .get_group (test , task_id )][test ]
212+ print (("%20s" % color_memory (result .Memory , package_util .get_memory_limit (test , config , lang , task_id , args )))
213213 if result .Memory is not None else 10 * " " , end = " | " )
214214 print ()
215215
@@ -277,9 +277,9 @@ def extract_file_name(self, file_path):
277277
278278
279279 def get_group (self , test_path ):
280- if package_util .extract_test_id (test_path ).endswith ("ocen" ):
280+ if package_util .extract_test_id (test_path , self . ID ).endswith ("ocen" ):
281281 return 0
282- return int ("" .join (filter (str .isdigit , package_util .extract_test_id (test_path ))))
282+ return int ("" .join (filter (str .isdigit , package_util .extract_test_id (test_path , self . ID ))))
283283
284284
285285 def get_executable_key (self , executable ):
@@ -604,7 +604,7 @@ def run_solution(self, data_for_execution: ExecutionData):
604604 """
605605
606606 (name , executable , test , time_limit , memory_limit , timetool_path ) = data_for_execution
607- file_no_ext = paths .get_executions_path (name , package_util .extract_test_id (test ))
607+ file_no_ext = paths .get_executions_path (name , package_util .extract_test_id (test , self . ID ))
608608 output_file = file_no_ext + ".out"
609609 result_file = file_no_ext + ".res"
610610 hard_time_limit_in_s = math .ceil (2 * time_limit / 1000.0 )
@@ -640,8 +640,10 @@ def run_solutions(self, compiled_commands, names, solutions):
640640 lang = package_util .get_file_lang (name )
641641 if result :
642642 for test in self .tests :
643- executions .append ((name , executable , test , package_util .get_time_limit (test , self .config , lang , self .args ),
644- package_util .get_memory_limit (test , self .config , lang , self .args ), self .timetool_path ))
643+ executions .append ((name , executable , test ,
644+ package_util .get_time_limit (test , self .config , lang , self .ID , self .args ),
645+ package_util .get_memory_limit (test , self .config , lang , self .ID , self .args ),
646+ self .timetool_path ))
645647 all_results [name ][self .get_group (test )][test ] = ExecutionResult (Status .PENDING )
646648 os .makedirs (paths .get_executions_path (name ), exist_ok = True )
647649 else :
@@ -658,8 +660,8 @@ def run_solutions(self, compiled_commands, names, solutions):
658660 run_event = threading .Event ()
659661 run_event .set ()
660662 thr = threading .Thread (target = printer .printer_thread ,
661- args = (run_event , print_view , program_groups_scores , all_results , print_data , names ,
662- executions , self .groups , self .scores , self .tests , self .possible_score ,
663+ args = (run_event , print_view , self . ID , program_groups_scores , all_results , print_data ,
664+ names , executions , self .groups , self .scores , self .tests , self .possible_score ,
663665 self .cpus , self .args .hide_memory , self .config , self .contest , self .args ))
664666 thr .start ()
665667
@@ -681,7 +683,7 @@ def run_solutions(self, compiled_commands, names, solutions):
681683 run_event .clear ()
682684 thr .join ()
683685
684- print ("\n " .join (print_view (terminal_width , terminal_height , program_groups_scores , all_results , print_data ,
686+ print ("\n " .join (print_view (terminal_width , terminal_height , self . ID , program_groups_scores , all_results , print_data ,
685687 names , executions , self .groups , self .scores , self .tests , self .possible_score ,
686688 self .cpus , self .args .hide_memory , self .config , self .contest , self .args )[0 ]))
687689
@@ -738,15 +740,15 @@ def get_whole_groups(self):
738740 Returns a list of groups for which all tests were run.
739741 """
740742 group_sizes = {}
741- for test in package_util .get_tests ():
742- group = package_util .get_group (test )
743+ for test in package_util .get_tests (self . ID ):
744+ group = package_util .get_group (test , self . ID )
743745 if group not in group_sizes :
744746 group_sizes [group ] = 0
745747 group_sizes [group ] += 1
746748
747749 run_group_sizes = {}
748750 for test in self .tests :
749- group = package_util .get_group (test )
751+ group = package_util .get_group (test , self . ID )
750752 if group not in run_group_sizes :
751753 run_group_sizes [group ] = 0
752754 run_group_sizes [group ] += 1
@@ -1027,7 +1029,7 @@ def exit(self):
10271029 cnt = len (self .failed_compilations ), letter = '' if len (self .failed_compilations ) == 1 else 's' ))
10281030
10291031 def set_scores (self ):
1030- self .tests = package_util .get_tests (self .args .tests )
1032+ self .tests = package_util .get_tests (self .ID , self . args .tests )
10311033 self .groups = self .get_groups (self .tests )
10321034 self .scores = collections .defaultdict (int )
10331035
@@ -1071,10 +1073,10 @@ def get_valid_input_files(self):
10711073 Returns list of input files that have corresponding output file.
10721074 """
10731075 output_tests = glob .glob (os .path .join (os .getcwd (), "out" , "*.out" ))
1074- output_tests_ids = [package_util .extract_test_id (test ) for test in output_tests ]
1076+ output_tests_ids = [package_util .extract_test_id (test , self . ID ) for test in output_tests ]
10751077 valid_input_files = []
10761078 for test in self .tests :
1077- if package_util .extract_test_id (test ) in output_tests_ids :
1079+ if package_util .extract_test_id (test , self . ID ) in output_tests_ids :
10781080 valid_input_files .append (test )
10791081 return valid_input_files
10801082
@@ -1129,6 +1131,7 @@ def run(self, args):
11291131 util .exit_if_not_package ()
11301132
11311133 self .set_constants ()
1134+ package_util .validate_test_names (self .ID )
11321135 self .args = args
11331136 with open (os .path .join (os .getcwd (), "config.yml" ), 'r' ) as config :
11341137 try :
@@ -1150,7 +1153,7 @@ def run(self, args):
11501153 print ("Task: %s (tag: %s)" % (title , self .ID ))
11511154 self .cpus = args .cpus or mp .cpu_count ()
11521155
1153- checker = glob . glob ( os . path . join ( os . getcwd (), "prog" , f'{ self .ID } chk.*' ) )
1156+ checker = package_util . get_files_matching_pattern ( self . ID , f'{ self .ID } chk.*' )
11541157 if len (checker ) != 0 :
11551158 print (util .info ("Checker found: %s" % os .path .basename (checker [0 ])))
11561159 self .checker = checker [0 ]
@@ -1163,7 +1166,7 @@ def run(self, args):
11631166 else :
11641167 self .checker = None
11651168
1166- lib = glob . glob ( os . path . join ( os . getcwd (), "prog" , f'{ self .ID } lib.*' ) )
1169+ lib = package_util . get_files_matching_pattern ( self . ID , f'{ self .ID } lib.*' )
11671170 self .has_lib = len (lib ) != 0
11681171
11691172 self .set_scores ()
@@ -1176,8 +1179,8 @@ def run(self, args):
11761179 lang = package_util .get_file_lang (solution )
11771180 for test in self .tests :
11781181 # The functions will exit if the limits are not set
1179- _ = package_util .get_time_limit (test , self .config , lang , self .args )
1180- _ = package_util .get_memory_limit (test , self .config , lang , self .args )
1182+ _ = package_util .get_time_limit (test , self .config , lang , self .ID , self . args )
1183+ _ = package_util .get_memory_limit (test , self .config , lang , self .ID , self . args )
11811184
11821185 results , all_results = self .compile_and_run (solutions )
11831186 self .check_errors (all_results )
0 commit comments