diff --git a/clearml/automation/optimization.py b/clearml/automation/optimization.py index 306be3a3..3b9c1e94 100644 --- a/clearml/automation/optimization.py +++ b/clearml/automation/optimization.py @@ -177,18 +177,19 @@ class Objective(object): # normalize value so we always look for the highest objective value return self.sign * objective - def get_top_tasks(self, top_k, optimizer_task_id=None): - # type: (int, Optional[str]) -> Sequence[Task] + def get_top_tasks(self, top_k, optimizer_task_id=None, task_filter=None): + # type: (int, Optional[str], Optional[dict]) -> Sequence[Task] """ Return a list of Tasks of the top performing experiments, based on the title/series objective. :param int top_k: The number of Tasks (experiments) to return. :param str optimizer_task_id: Parent optimizer Task ID + :param dict task_filter: Optional task_filtering for the query :return: A list of Task objects, ordered by performance, where index 0 is the best performing Task. """ - - task_filter = {'page_size': int(top_k), 'page': 0} + task_filter = deepcopy(task_filter) if task_filter else {} + task_filter.update({'page_size': int(top_k), 'page': 0}) if optimizer_task_id: task_filter['parent'] = optimizer_task_id order_by = self._get_last_metrics_encode_field()