@@ -26,12 +26,22 @@ class TaskWrapper:
2626
2727 task : Task
2828 batch_id : Union [int , str ]
29- sub_task_num : int = 1
29+ sub_task_num : int = 1 # number of sub tasks splitted from this task
30+ # if max_repeat_times_per_runner is set, one task may be splitted into multiple sub tasks
3031 results : List [Tuple [Status , List [Experience ]]] = field (default_factory = list )
3132
3233
3334def calculate_task_level_metrics (metrics : List [Dict ]) -> Dict [str , float ]:
34- """Calculate task level metrics from experiences."""
35+ """Calculate task level metrics (mean) from multiple runs of the same task.
36+
37+ Args:
38+ metrics (`List[Dict]`): A list of metric dictionaries from multiple runs of the same task.
39+
40+ Returns:
41+ `Dict[str, float]`: A dictionary of aggregated metrics, where each metric is averaged over all runs.
42+
43+ TODO: support more aggregation methods like max, min.
44+ """
3545 if not metrics :
3646 return {}
3747 aggregated_metrics : Dict [str , List [float ]] = defaultdict (list )
@@ -312,11 +322,13 @@ def task_done_callback(self, async_task: asyncio.Task):
312322 return
313323 else :
314324 status , exps , runner_id , run_time = async_task .result ()
315- self .total_running_time += run_time
316- self .total_completed_tasks += 1
325+ if not task .task .is_eval : # only count running time for non-eval tasks
326+ self .total_running_time += run_time
327+ self .total_completed_tasks += 1
317328 task .results .append ((status , exps ))
318329 self .busy_runners .pop (runner_id )
319330 self .idle_runners .add (runner_id )
331+ # If all sub runs in a task are completed
320332 if len (task .results ) == task .sub_task_num :
321333 task_experiences = []
322334 task_metrics = []
@@ -326,6 +338,7 @@ def task_done_callback(self, async_task: asyncio.Task):
326338 task_experiences .extend (exp )
327339 if not s .ok :
328340 all_success = False
341+ # calculate task level metrics
329342 task_status = Status (
330343 ok = all_success , metrics = [calculate_task_level_metrics (task_metrics )]
331344 )
0 commit comments