diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml index eb7a5f79..32e170d9 100644 --- a/.code-samples.meilisearch.yaml +++ b/.code-samples.meilisearch.yaml @@ -623,8 +623,8 @@ get_all_tasks_filtering_1: |- client.get_tasks({'indexUid': ['movies']}) get_all_tasks_filtering_2: |- client.get_tasks({ - 'status': ['succeeded', 'failed'], - 'type': ['documentAdditionOrUpdate'] + 'statuses': ['succeeded', 'failed'], + 'types': ['documentAdditionOrUpdate'] }) get_all_tasks_paginating_1: |- client.get_tasks({ diff --git a/meilisearch/client.py b/meilisearch/client.py index 16f73e97..6056c42f 100644 --- a/meilisearch/client.py +++ b/meilisearch/client.py @@ -407,8 +407,7 @@ def get_tasks( Parameters ---------- parameters (optional): - parameters accepted by the get tasks route: https://docs.meilisearch.com/reference/api/tasks.html#get-all-tasks. - `indexUid` should be set as a List. + parameters accepted by the get tasks route: https://docs.meilisearch.com/reference/api/tasks.html#get-tasks. Returns ------- diff --git a/meilisearch/index.py b/meilisearch/index.py index 02ec031e..87f8a010 100644 --- a/meilisearch/index.py +++ b/meilisearch/index.py @@ -49,6 +49,12 @@ def __init__( def delete(self) -> dict[str, Any]: """Delete the index. + Returns + ------- + task_info: + TaskInfo instance containing information about a task to track the progress of an asynchronous process. + https://docs.meilisearch.com/reference/api/tasks.html#get-one-task + Raises ------ MeiliSearchApiError @@ -67,8 +73,8 @@ def update(self, primary_key: str) -> dict[str, Any]: Returns ------- - task: - Dictionary containing a task to track the informations about the progress of an asynchronous process. + task_info: + TaskInfo instance containing information about a task to track the progress of an asynchronous process. https://docs.meilisearch.com/reference/api/tasks.html#get-one-task Raises @@ -116,8 +122,8 @@ def create(config: Config, uid: str, options: dict[str, Any] | None = None) -> d Returns ------- - task: - Dictionary containing a task to track the informations about the progress of an asynchronous process. + task_info: + TaskInfo instance containing information about a task to track the progress of an asynchronous process. https://docs.meilisearch.com/reference/api/tasks.html#get-one-task Raises @@ -136,8 +142,7 @@ def get_tasks(self, parameters: dict[str, Any] | None = None) -> TaskResults: Parameters ---------- parameters (optional): - parameters accepted by the get tasks route: https://docs.meilisearch.com/reference/api/tasks.html#get-all-tasks. - `indexUid` should be set as a List. + parameters accepted by the get tasks route: https://docs.meilisearch.com/reference/api/tasks.html#get-tasks. Returns ------- @@ -154,9 +159,9 @@ def get_tasks(self, parameters: dict[str, Any] | None = None) -> TaskResults: An error containing details about why Meilisearch can't process your request. Meilisearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ if parameters is not None: - parameters.setdefault("indexUid", []).append(self.uid) + parameters.setdefault("indexUids", []).append(self.uid) else: - parameters = {"indexUid": [self.uid]} + parameters = {"indexUids": [self.uid]} tasks = get_tasks(self.config, parameters=parameters) return TaskResults(tasks) @@ -756,8 +761,8 @@ def update_settings(self, body: dict[str, Any]) -> dict[str, Any]: Returns ------- - task: - Dictionary containing a task to track the informations about the progress of an asynchronous process. + task_info: + TaskInfo instance containing information about a task to track the progress of an asynchronous process. https://docs.meilisearch.com/reference/api/tasks.html#get-one-task Raises @@ -776,8 +781,8 @@ def reset_settings(self) -> dict[str, Any]: Returns ------- - task: - Dictionary containing a task to track the informations about the progress of an asynchronous process. + task_info: + TaskInfo instance containing information about a task to track the progress of an asynchronous process. https://docs.meilisearch.com/reference/api/tasks.html#get-one-task Raises @@ -814,8 +819,8 @@ def update_ranking_rules(self, body: list[str]) -> dict[str, Any]: Returns ------- - task: - Dictionary containing a task to track the informations about the progress of an asynchronous process. + task_info: + TaskInfo instance containing information about a task to track the progress of an asynchronous process. https://docs.meilisearch.com/reference/api/tasks.html#get-one-task Raises @@ -830,8 +835,8 @@ def reset_ranking_rules(self) -> dict[str, Any]: Returns ------- - task: - Dictionary containing a task to track the informations about the progress of an asynchronous process. + task_info: + TaskInfo instance containing information about a task to track the progress of an asynchronous process. https://docs.meilisearch.com/reference/api/tasks.html#get-one-task Raises @@ -870,8 +875,8 @@ def update_distinct_attribute(self, body: dict[str, Any]) -> dict[str, Any]: Returns ------- - task: - Dictionary containing a task to track the informations about the progress of an asynchronous process. + task_info: + TaskInfo instance containing information about a task to track the progress of an asynchronous process. https://docs.meilisearch.com/reference/api/tasks.html#get-one-task Raises @@ -886,8 +891,8 @@ def reset_distinct_attribute(self) -> dict[str, Any]: Returns ------- - task: - Dictionary containing a task to track the informations about the progress of an asynchronous process. + task_info: + TaskInfo instance containing information about a task to track the progress of an asynchronous process. https://docs.meilisearch.com/reference/api/tasks.html#get-one-task Raises @@ -926,8 +931,8 @@ def update_searchable_attributes(self, body: list[str]) -> dict[str, Any]: Returns ------- - task: - Dictionary containing a task to track the informations about the progress of an asynchronous process. + task_info: + TaskInfo instance containing information about a task to track the progress of an asynchronous process. https://docs.meilisearch.com/reference/api/tasks.html#get-one-task Raises @@ -942,8 +947,8 @@ def reset_searchable_attributes(self) -> dict[str, Any]: Returns ------- - task: - Dictionary containing a task to track the informations about the progress of an asynchronous process. + task_info: + TaskInfo instance containing information about a task to track the progress of an asynchronous process. https://docs.meilisearch.com/reference/api/tasks.html#get-one-task Raises @@ -982,8 +987,8 @@ def update_displayed_attributes(self, body: list[str]) -> dict[str, Any]: Returns ------- - task: - Dictionary containing a task to track the informations about the progress of an asynchronous process. + task_info: + TaskInfo instance containing information about a task to track the progress of an asynchronous process. https://docs.meilisearch.com/reference/api/tasks.html#get-one-task Raises @@ -998,8 +1003,8 @@ def reset_displayed_attributes(self) -> dict[str, Any]: Returns ------- - task: - Dictionary containing a task to track the informations about the progress of an asynchronous process. + task_info: + TaskInfo instance containing information about a task to track the progress of an asynchronous process. https://docs.meilisearch.com/reference/api/tasks.html#get-one-task Raises @@ -1038,8 +1043,8 @@ def update_stop_words(self, body: list[str]) -> dict[str, Any]: Returns ------- - task: - Dictionary containing a task to track the informations about the progress of an asynchronous process. + task_info: + TaskInfo instance containing information about a task to track the progress of an asynchronous process. https://docs.meilisearch.com/reference/api/tasks.html#get-one-task Raises @@ -1054,8 +1059,8 @@ def reset_stop_words(self) -> dict[str, Any]: Returns ------- - task: - Dictionary containing a task to track the informations about the progress of an asynchronous process. + task_info: + TaskInfo instance containing information about a task to track the progress of an asynchronous process. https://docs.meilisearch.com/reference/api/tasks.html#get-one-task Raises @@ -1094,8 +1099,8 @@ def update_synonyms(self, body: dict[str, list[str]]) -> dict[str, Any]: Returns ------- - task: - Dictionary containing a task to track the informations about the progress of an asynchronous process. + task_info: + TaskInfo instance containing information about a task to track the progress of an asynchronous process. https://docs.meilisearch.com/reference/api/tasks.html#get-one-task Raises @@ -1110,8 +1115,8 @@ def reset_synonyms(self) -> dict[str, Any]: Returns ------- - task: - Dictionary containing a task to track the informations about the progress of an asynchronous process. + task_info: + TaskInfo instance containing information about a task to track the progress of an asynchronous process. https://docs.meilisearch.com/reference/api/tasks.html#get-one-task Raises @@ -1150,8 +1155,8 @@ def update_filterable_attributes(self, body: list[str]) -> dict[str, Any]: Returns ------- - task: - Dictionary containing a task to track the informations about the progress of an asynchronous process. + task_info: + TaskInfo instance containing information about a task to track the progress of an asynchronous process. https://docs.meilisearch.com/reference/api/tasks.html#get-one-task Raises @@ -1166,8 +1171,8 @@ def reset_filterable_attributes(self) -> dict[str, Any]: Returns ------- - task: - Dictionary containing a task to track the informations about the progress of an asynchronous process. + task_info: + TaskInfo instance containing information about a task to track the progress of an asynchronous process. https://docs.meilisearch.com/reference/api/tasks.html#get-one-task Raises @@ -1206,8 +1211,8 @@ def update_sortable_attributes(self, body: list[str]) -> dict[str, Any]: Returns ------- - task: - Dictionary containing a task to track the informations about the progress of an asynchronous process. + task_info: + TaskInfo instance containing information about a task to track the progress of an asynchronous process. https://docs.meilisearch.com/reference/api/tasks.html#get-one-task Raises @@ -1222,8 +1227,8 @@ def reset_sortable_attributes(self) -> dict[str, Any]: Returns ------- - task: - Dictionary containing a task to track the informations about the progress of an asynchronous process. + task_info: + TaskInfo instance containing information about a task to track the progress of an asynchronous process. https://docs.meilisearch.com/reference/api/tasks.html#get-one-task Raises @@ -1262,8 +1267,8 @@ def update_typo_tolerance(self, body: dict[str, Any]) -> dict[str, Any]: Returns ------- - task: - Dictionary containing a task to track the informations about the progress of an asynchronous process. + task_info: + TaskInfo instance containing information about a task to track the progress of an asynchronous process. https://docs.meilisearch.com/reference/api/tasks.html#get-one-task Raises @@ -1278,8 +1283,8 @@ def reset_typo_tolerance(self) -> dict[str, Any]: Returns ------- - task: - Dictionary containing a task to track the informations about the progress of an asynchronous process. + task_info: + TaskInfo instance containing information about a task to track the progress of an asynchronous process. https://docs.meilisearch.com/reference/api/tasks.html#get-one-task Raises @@ -1317,8 +1322,8 @@ def update_pagination_settings(self, body: dict[str, Any]) -> dict[str, Any]: Returns ------- - task: - Dictionary containing a task to track the informations about the progress of an asynchronous process. + task_info: + TaskInfo instance containing information about a task to track the progress of an asynchronous process. https://docs.meilisearch.com/reference/api/tasks.html#get-one-task Raises @@ -1335,8 +1340,8 @@ def reset_pagination_settings(self) -> dict[str, Any]: Returns ------- - task: - Dictionary containing a task to track the informations about the progress of an asynchronous process. + task_info: + TaskInfo instance containing information about a task to track the progress of an asynchronous process. https://docs.meilisearch.com/reference/api/tasks.html#get-one-task Raises @@ -1373,8 +1378,8 @@ def update_faceting_settings(self, body: dict[str, Any]) -> dict[str, Any]: Returns ------- - task: - Dictionary containing a task to track the informations about the progress of an asynchronous process. + task_info: + TaskInfo instance containing information about a task to track the progress of an asynchronous process. https://docs.meilisearch.com/reference/api/tasks.html#get-one-task Raises @@ -1389,8 +1394,8 @@ def reset_faceting_settings(self) -> dict[str, Any]: Returns ------- - task: - Dictionary containing a task to track the informations about the progress of an asynchronous process. + task_info: + TaskInfo instance containing information about a task to track the progress of an asynchronous process. https://docs.meilisearch.com/reference/api/tasks.html#get-one-task Raises diff --git a/meilisearch/task.py b/meilisearch/task.py index 8358f5ee..03276481 100644 --- a/meilisearch/task.py +++ b/meilisearch/task.py @@ -20,8 +20,7 @@ def get_tasks( config: Config object containing permission and location of Meilisearch. parameters (optional): - parameters accepted by the get tasks route: https://docs.meilisearch.com/reference/api/tasks.html#get-all-tasks. - `indexUid` should be set as a List. + parameters accepted by the get tasks route: https://docs.meilisearch.com/reference/api/tasks.html#get-tasks. Returns ------- diff --git a/tests/client/test_client_task_meilisearch.py b/tests/client/test_client_task_meilisearch.py index 2134572e..0085d8c2 100644 --- a/tests/client/test_client_task_meilisearch.py +++ b/tests/client/test_client_task_meilisearch.py @@ -29,17 +29,42 @@ def test_get_tasks_empty_parameters(client): assert isinstance(tasks["results"], list) -def test_get_tasks_with_parameters(client): +def test_get_tasks_with_parameters(client, empty_index): """Tests getting the global tasks list after populating an index.""" - tasks = client.get_tasks({"limit": 1, "from": 1}) + empty_index() + tasks = client.get_tasks({"limit": 1}) assert isinstance(tasks, dict) assert len(tasks["results"]) == 1 - assert tasks["results"][0]["uid"] == 1 -def test_get_tasks_with_index_uid(client): +def test_get_tasks_with_all_plural_parameters(client, empty_index): + """Tests getting the global tasks list after populating an index.""" + empty_index() + tasks = client.get_tasks( + {"indexUids": [common.INDEX_UID], "statuses": ["succeeded"], "types": ["indexCreation"]} + ) + assert isinstance(tasks, dict) + assert len(tasks["results"]) > 1 + + +def test_get_tasks_with_date_parameters(client, empty_index): """Tests getting the global tasks list after populating an index.""" - tasks = client.get_tasks({"limit": 1, "indexUid": [common.INDEX_UID]}) + empty_index() + tasks = client.get_tasks( + { + "beforeEnqueuedAt": "2042-04-02T00:42:42Z", + "beforeStartedAt": "2042-04-02T00:42:42Z", + "beforeFinishedAt": "2042-04-02T00:42:42Z", + } + ) + assert isinstance(tasks, dict) + assert len(tasks["results"]) > 1 + + +def test_get_tasks_with_index_uid(client, empty_index): + """Tests getting the global tasks list after populating an index.""" + empty_index() + tasks = client.get_tasks({"limit": 1, "indexUids": [common.INDEX_UID]}) assert isinstance(tasks, dict) assert len(tasks["results"]) == 1 @@ -50,7 +75,7 @@ def test_get_task(client): client.wait_for_task(response["taskUid"]) task = client.get_task(response["taskUid"]) assert isinstance(task, dict) - assert len(task) == 9 + assert len(task) == 11 assert "uid" in task assert "indexUid" in task assert "status" in task diff --git a/tests/index/test_index_task_meilisearch.py b/tests/index/test_index_task_meilisearch.py index 4bc0be67..46702667 100644 --- a/tests/index/test_index_task_meilisearch.py +++ b/tests/index/test_index_task_meilisearch.py @@ -37,7 +37,7 @@ def test_get_tasks_with_parameters(empty_index): def test_get_tasks_with_index_uid(empty_index): """Tests getting the tasks list of a populated index.""" index = empty_index() - tasks = index.get_tasks({"limit": 1, "indexUid": [common.INDEX_UID]}) + tasks = index.get_tasks({"limit": 1, "indexUids": [common.INDEX_UID]}) assert isinstance(tasks, TaskResults) assert len(tasks.results) == 1