Skip to content

Commit

Permalink
Rename some task filter and fix tests for v0.30.0
Browse files Browse the repository at this point in the history
  • Loading branch information
alallema committed Nov 16, 2022
1 parent 2fe2b81 commit 5a9776d
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 69 deletions.
4 changes: 2 additions & 2 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
3 changes: 1 addition & 2 deletions meilisearch/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------
Expand Down
117 changes: 61 additions & 56 deletions meilisearch/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
-------
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions meilisearch/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------
Expand Down
13 changes: 7 additions & 6 deletions tests/client/test_client_task_meilisearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,18 @@ 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_index_uid(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({"limit": 1, "indexUids": [common.INDEX_UID]})
assert isinstance(tasks, dict)
assert len(tasks["results"]) == 1

Expand All @@ -50,7 +51,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
Expand Down
2 changes: 1 addition & 1 deletion tests/index/test_index_task_meilisearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 5a9776d

Please sign in to comment.