From 8ba78b5a11e038542252b07099a7c7facdf50a8c Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Thu, 22 Dec 2022 21:58:13 +0200 Subject: [PATCH] Add `allow_archived` argument in `Task.get_tasks()` --- clearml/task.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/clearml/task.py b/clearml/task.py index c1be12dc..d612a6cb 100644 --- a/clearml/task.py +++ b/clearml/task.py @@ -951,6 +951,7 @@ class Task(_Task): project_name=None, # type: Optional[Union[Sequence[str],str]] task_name=None, # type: Optional[str] tags=None, # type: Optional[Sequence[str]] + allow_archived=True, # type: bool task_filter=None # type: Optional[Dict] ): # type: (...) -> List[TaskInstance] @@ -983,6 +984,7 @@ class Task(_Task): If None is passed, returns all tasks within the project :param list tags: Filter based on the requested list of tags (strings) (Task must have all the listed tags) To exclude a tag add "-" prefix to the tag. Example: ["best", "-debug"] + :param bool allow_archived: If True (default) allow to return archived Tasks, if False filter out archived Tasks :param dict task_filter: filter and order Tasks. See service.tasks.GetAllRequest for details `parent`: (str) filter by parent task-id matching `search_text`: (str) free text search (in task fields comment/name/id) @@ -1009,8 +1011,12 @@ class Task(_Task): :return: The Tasks specified by the parameter combinations (see the parameters). :rtype: List[Task] """ + task_filter = task_filter or {} + if not allow_archived: + task_filter['system_tags'] = (task_filter.get('system_tags') or []) + ['-{}'.format(cls.archived_tag)] + return cls.__get_tasks(task_ids=task_ids, project_name=project_name, tags=tags, - task_name=task_name, **(task_filter or {})) + task_name=task_name, **task_filter) @classmethod def query_tasks(