Improve docstrings for tag filters

This commit is contained in:
allegroai 2023-11-07 15:07:41 +02:00
parent fdd2c03900
commit f67ce9c04b
2 changed files with 94 additions and 16 deletions

View File

@ -1426,12 +1426,31 @@ class Model(BaseModel):
:param project_name: Optional, filter based project name string, if not given query models from all projects :param project_name: Optional, filter based project name string, if not given query models from all projects
:param model_name: Optional Model name as shown in the model artifactory :param model_name: Optional Model name as shown in the model artifactory
:param tags: Filter based on the requested list of tags (strings) :param tags: Filter based on the requested list of tags (strings).
To exclude a tag add "-" prefix to the tag. Example: ['production', 'verified', '-qa'] To exclude a tag add "-" prefix to the tag. Example: ``["production", "verified", "-qa"]``.
To include All tags (instead of the default Any behaviour) use "__$all" as the first string, example: The default behaviour is to join all tags with a logical "OR" operator.
To join all tags with a logical "AND" operator instead, use "__$all" as the first string, for example:
.. code-block:: py
["__$all", "best", "model", "ever"] ["__$all", "best", "model", "ever"]
To combine All tags and exclude a list of tags use "__$not" before the excluded tags, example:
To join all tags with AND, but exclude a tag use "__$not" before the excluded tag, for example:
.. code-block:: py
["__$all", "best", "model", "ever", "__$not", "internal", "__$not", "test"] ["__$all", "best", "model", "ever", "__$not", "internal", "__$not", "test"]
The "OR" and "AND" operators apply to all tags that follow them until another operator is specified.
The NOT operator applies only to the immediately following tag.
For example:
.. code-block:: py
["__$all", "a", "b", "c", "__$or", "d", "__$not", "e", "__$and", "__$or" "f", "g"]
This example means ("a" AND "b" AND "c" AND ("d" OR NOT "e") AND ("f" OR "g")).
See https://clear.ml/docs/latest/docs/clearml_sdk/model_sdk#tag-filters for details.
:param only_published: If True, only return published models. :param only_published: If True, only return published models.
:param include_archived: If True, return archived models. :param include_archived: If True, return archived models.
:param max_results: Optional return the last X models, :param max_results: Optional return the last X models,

View File

@ -931,8 +931,31 @@ class Task(_Task):
If specified, ``project_name`` and ``task_name`` are ignored. If specified, ``project_name`` and ``task_name`` are ignored.
:param str project_name: The project name of the Task to get. :param str project_name: The project name of the Task to get.
:param str task_name: The name of the Task within ``project_name`` to get. :param str task_name: The name of the Task within ``project_name`` to get.
:param list tags: Filter based on the requested list of tags (strings) (Task must have at least one of the :param list tags: Filter based on the requested list of tags (strings). To exclude a tag add "-" prefix to the
listed tags). To exclude a tag add "-" prefix to the tag. Example: ["best", "-debug"] tag. Example: ``["best", "-debug"]``.
The default behaviour is to join all tags with a logical "OR" operator.
To join all tags with a logical "AND" operator instead, use "__$all" as the first string, for example:
.. code-block:: py
["__$all", "best", "experiment", "ever"]
To join all tags with AND, but exclude a tag use "__$not" before the excluded tag, for example:
.. code-block:: py
["__$all", "best", "experiment", "ever", "__$not", "internal", "__$not", "test"]
The "OR" and "AND" operators apply to all tags that follow them until another operator is specified.
The NOT operator applies only to the immediately following tag.
For example:
.. code-block:: py
["__$all", "a", "b", "c", "__$or", "d", "__$not", "e", "__$and", "__$or" "f", "g"]
This example means ("a" AND "b" AND "c" AND ("d" OR NOT "e") AND ("f" OR "g")).
See https://clear.ml/docs/latest/docs/clearml_sdk/task_sdk/#tag-filters for more information.
:param bool allow_archived: Only applicable if *not* using specific ``task_id``, :param bool allow_archived: Only applicable if *not* using specific ``task_id``,
If True (default), allow to return archived Tasks, if False filter out archived Tasks If True (default), allow to return archived Tasks, if False filter out archived Tasks
:param bool task_filter: Only applicable if *not* using specific ``task_id``, :param bool task_filter: Only applicable if *not* using specific ``task_id``,
@ -980,8 +1003,31 @@ class Task(_Task):
avoid any regex behaviour, use re.escape()). (Optional) avoid any regex behaviour, use re.escape()). (Optional)
To match an exact task name (i.e. not partial matching), To match an exact task name (i.e. not partial matching),
add ^/$ at the beginning/end of the string, for example: "^exact_task_name_here$" add ^/$ at the beginning/end of the string, for example: "^exact_task_name_here$"
:param list tags: Filter based on the requested list of tags (strings) (Task must have all the listed tags) :param list tags: Filter based on the requested list of tags (strings). To exclude a tag add "-" prefix to the
To exclude a tag add "-" prefix to the tag. Example: ["best", "-debug"] tag. Example: ``["best", "-debug"]``.
The default behaviour is to join all tags with a logical "OR" operator.
To join all tags with a logical "AND" operator instead, use "__$all" as the first string, for example:
.. code-block:: py
["__$all", "best", "experiment", "ever"]
To join all tags with AND, but exclude a tag use "__$not" before the excluded tag, for example:
.. code-block:: py
["__$all", "best", "experiment", "ever", "__$not", "internal", "__$not", "test"]
The "OR" and "AND" operators apply to all tags that follow them until another operator is specified.
The NOT operator applies only to the immediately following tag.
For example:
.. code-block:: py
["__$all", "a", "b", "c", "__$or", "d", "__$not", "e", "__$and", "__$or" "f", "g"]
This example means ("a" AND "b" AND "c" AND ("d" OR NOT "e") AND ("f" OR "g")).
See https://clear.ml/docs/latest/docs/clearml_sdk/task_sdk/#tag-filters for more information.
:param bool allow_archived: If True (default), allow to return archived Tasks, if False filter out archived Tasks :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. :param dict task_filter: filter and order Tasks.
See :class:`.backend_api.service.v?.tasks.GetAllRequest` for details; the ? needs to be replaced by the appropriate version. See :class:`.backend_api.service.v?.tasks.GetAllRequest` for details; the ? needs to be replaced by the appropriate version.
@ -1032,17 +1078,30 @@ class Task(_Task):
:param str task_name: task name (str) within the selected project :param str task_name: task name (str) within the selected project
Return any partial match of task_name, regular expressions matching is also supported. Return any partial match of task_name, regular expressions matching is also supported.
If None is passed, returns all tasks within the project If None is passed, returns all tasks within the project
:param list tags: Filter based on the requested list of tags (strings) :param list tags: Filter based on the requested list of tags (strings).
To exclude a tag add "-" prefix to the tag. Example: ["best", "-debug"] To exclude a tag add "-" prefix to the tag. Example: ``["best", "-debug"]``.
The default behaviour is to join all tags with a logical "OR" operator. The default behaviour is to join all tags with a logical "OR" operator.
To join all tags with a logical "AND" operator instead, use "__$all" as the first string, for example: To join all tags with a logical "AND" operator instead, use "__$all" as the first string, for example:
.. code-block:: py
["__$all", "best", "experiment", "ever"] ["__$all", "best", "experiment", "ever"]
To join all tags with AND, but exclude a tag use "__$not" before the excluded tag, for example: To join all tags with AND, but exclude a tag use "__$not" before the excluded tag, for example:
.. code-block:: py
["__$all", "best", "experiment", "ever", "__$not", "internal", "__$not", "test"] ["__$all", "best", "experiment", "ever", "__$not", "internal", "__$not", "test"]
The "OR" and "AND" operators apply to all tags that follow them until another operator is specified. The "OR" and "AND" operators apply to all tags that follow them until another operator is specified.
The NOT operator applies only to the immediately following tag. The NOT operator applies only to the immediately following tag.
For example, ["__$all", "a", "b", "c", "__$or", "d", "__$not", "e", "__$and", "__$or" "f", "g"] For example:
means ("a" AND "b" AND "c" AND ("d" OR NOT "e") AND ("f" OR "g")).
.. code-block:: py
["__$all", "a", "b", "c", "__$or", "d", "__$not", "e", "__$and", "__$or" "f", "g"]
This example means ("a" AND "b" AND "c" AND ("d" OR NOT "e") AND ("f" OR "g")).
See https://clear.ml/docs/latest/docs/clearml_sdk/task_sdk/#tag-filters for more information. See https://clear.ml/docs/latest/docs/clearml_sdk/task_sdk/#tag-filters for more information.
:param list additional_return_fields: Optional, if not provided return a list of Task IDs. :param list additional_return_fields: Optional, if not provided return a list of Task IDs.
If provided return dict per Task with the additional requested fields. If provided return dict per Task with the additional requested fields.