meilisearch-python-sdk 3.6.1__tar.gz → 4.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of meilisearch-python-sdk might be problematic. Click here for more details.
- meilisearch_python_sdk-4.0.0/.github/renovate.json5 +10 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/.github/workflows/docs_publish.yml +1 -1
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/.github/workflows/nightly_testing.yml +1 -1
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/.github/workflows/pypi_publish.yml +1 -1
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/.github/workflows/testing.yml +10 -10
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/.pre-commit-config.yaml +1 -1
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/PKG-INFO +2 -2
- meilisearch_python_sdk-4.0.0/examples/requirements.txt +4 -0
- meilisearch_python_sdk-4.0.0/meilisearch_python_sdk/_batch.py +52 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/meilisearch_python_sdk/_client.py +24 -4
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/meilisearch_python_sdk/_http_requests.py +2 -2
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/meilisearch_python_sdk/_task.py +29 -29
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/meilisearch_python_sdk/_utils.py +25 -0
- meilisearch_python_sdk-4.0.0/meilisearch_python_sdk/_version.py +1 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/meilisearch_python_sdk/errors.py +4 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/meilisearch_python_sdk/index.py +282 -0
- meilisearch_python_sdk-4.0.0/meilisearch_python_sdk/models/batch.py +55 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/meilisearch_python_sdk/models/settings.py +3 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/meilisearch_python_sdk/models/task.py +2 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/pyproject.toml +14 -12
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/tests/conftest.py +2 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/tests/test_async_client.py +61 -2
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/tests/test_async_index.py +64 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/tests/test_async_search.py +6 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/tests/test_client.py +58 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/tests/test_index.py +65 -1
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/tests/test_search.py +6 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/uv.lock +464 -415
- meilisearch_python_sdk-3.6.1/.github/dependabot.yaml +0 -16
- meilisearch_python_sdk-3.6.1/examples/requirements.txt +0 -4
- meilisearch_python_sdk-3.6.1/meilisearch_python_sdk/_version.py +0 -1
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/.github/FUNDING.yml +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/.github/release-draft-template.yaml +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/.github/workflows/release-drafter.yml +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/.gitignore +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/CONTRIBUTING.md +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/LICENSE +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/README.md +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/assets/add_in_batches.png +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/assets/searches.png +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/benchmark/run_benchmark.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/codecov.yml +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/datasets/small_movies.json +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/docker-compose.https.yml +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/docker-compose.yml +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/docs/.nojekyll +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/docs/CNAME +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/docs/async_client_api.md +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/docs/async_index_api.md +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/docs/client_api.md +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/docs/css/custom.css +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/docs/decorators_api.md +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/docs/index.md +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/docs/index_api.md +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/docs/js/umami.js +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/docs/json_handler.md +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/docs/plugins.md +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/docs/pydantic.md +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/examples/.gitignore +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/examples/README.md +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/examples/__init__.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/examples/add_documents_decorator.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/examples/add_documents_in_batches.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/examples/async_add_documents_decorator.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/examples/async_add_documents_in_batches.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/examples/async_documents_and_search_results.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/examples/async_search_tracker.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/examples/async_update_settings.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/examples/documents_and_search_results.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/examples/fastapi_example.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/examples/orjson_example.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/examples/pyproject.toml +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/examples/search_tracker.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/examples/tests/__init__.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/examples/tests/conftest.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/examples/tests/test_async_examples.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/examples/tests/test_examples.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/examples/ujson_example.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/examples/update_settings.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/justfile +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/meilisearch_python_sdk/__init__.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/meilisearch_python_sdk/decorators.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/meilisearch_python_sdk/json_handler.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/meilisearch_python_sdk/models/__init__.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/meilisearch_python_sdk/models/client.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/meilisearch_python_sdk/models/documents.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/meilisearch_python_sdk/models/health.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/meilisearch_python_sdk/models/index.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/meilisearch_python_sdk/models/search.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/meilisearch_python_sdk/models/version.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/meilisearch_python_sdk/plugins.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/meilisearch_python_sdk/py.typed +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/meilisearch_python_sdk/types.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/mkdocs.yaml +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/tests/__init__.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/tests/test_async_documents.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/tests/test_async_index_plugins.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/tests/test_decorators.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/tests/test_documents.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/tests/test_errors.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/tests/test_index_plugins.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/tests/test_utils.py +0 -0
- {meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/tests/test_version.py +0 -0
|
@@ -15,7 +15,7 @@ jobs:
|
|
|
15
15
|
- name: install Just
|
|
16
16
|
uses: taiki-e/install-action@just
|
|
17
17
|
- name: Install uv
|
|
18
|
-
uses: astral-sh/setup-uv@
|
|
18
|
+
uses: astral-sh/setup-uv@v5
|
|
19
19
|
with:
|
|
20
20
|
enable-cache: true
|
|
21
21
|
- name: Set up Python
|
|
@@ -38,7 +38,7 @@ jobs:
|
|
|
38
38
|
- name: install Just
|
|
39
39
|
uses: taiki-e/install-action@just
|
|
40
40
|
- name: Install uv
|
|
41
|
-
uses: astral-sh/setup-uv@
|
|
41
|
+
uses: astral-sh/setup-uv@v5
|
|
42
42
|
with:
|
|
43
43
|
enable-cache: true
|
|
44
44
|
- name: Set up Python ${{ matrix.python-version }}
|
|
@@ -50,7 +50,7 @@ jobs:
|
|
|
50
50
|
- name: Test with pytest
|
|
51
51
|
run: just test-parallel-ci
|
|
52
52
|
- name: Upload coverage
|
|
53
|
-
uses: codecov/codecov-action@
|
|
53
|
+
uses: codecov/codecov-action@v5
|
|
54
54
|
with:
|
|
55
55
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
56
56
|
fail_ci_if_error: true
|
|
@@ -66,7 +66,7 @@ jobs:
|
|
|
66
66
|
- name: install Just
|
|
67
67
|
uses: taiki-e/install-action@just
|
|
68
68
|
- name: Install uv
|
|
69
|
-
uses: astral-sh/setup-uv@
|
|
69
|
+
uses: astral-sh/setup-uv@v5
|
|
70
70
|
with:
|
|
71
71
|
enable-cache: true
|
|
72
72
|
- name: Set up Python ${{ matrix.python-version }}
|
|
@@ -90,7 +90,7 @@ jobs:
|
|
|
90
90
|
- name: Test with pytest
|
|
91
91
|
run: just test-parallel-ci-http2
|
|
92
92
|
- name: Upload coverage
|
|
93
|
-
uses: codecov/codecov-action@
|
|
93
|
+
uses: codecov/codecov-action@v5
|
|
94
94
|
with:
|
|
95
95
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
96
96
|
fail_ci_if_error: true
|
|
@@ -106,7 +106,7 @@ jobs:
|
|
|
106
106
|
- name: install Just
|
|
107
107
|
uses: taiki-e/install-action@just
|
|
108
108
|
- name: Install uv
|
|
109
|
-
uses: astral-sh/setup-uv@
|
|
109
|
+
uses: astral-sh/setup-uv@v5
|
|
110
110
|
with:
|
|
111
111
|
enable-cache: true
|
|
112
112
|
- name: Set up Python ${{ matrix.python-version }}
|
|
@@ -118,7 +118,7 @@ jobs:
|
|
|
118
118
|
- name: Test with pytest
|
|
119
119
|
run: just test-no-parallel-ci
|
|
120
120
|
- name: Upload coverage
|
|
121
|
-
uses: codecov/codecov-action@
|
|
121
|
+
uses: codecov/codecov-action@v5
|
|
122
122
|
with:
|
|
123
123
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
124
124
|
fail_ci_if_error: true
|
|
@@ -134,7 +134,7 @@ jobs:
|
|
|
134
134
|
- name: install Just
|
|
135
135
|
uses: taiki-e/install-action@just
|
|
136
136
|
- name: Install uv
|
|
137
|
-
uses: astral-sh/setup-uv@
|
|
137
|
+
uses: astral-sh/setup-uv@v5
|
|
138
138
|
with:
|
|
139
139
|
enable-cache: true
|
|
140
140
|
- name: Set up Python ${{ matrix.python-version }}
|
|
@@ -158,7 +158,7 @@ jobs:
|
|
|
158
158
|
- name: Test with pytest
|
|
159
159
|
run: just test-no-parallel-ci-http2
|
|
160
160
|
- name: Upload coverage
|
|
161
|
-
uses: codecov/codecov-action@
|
|
161
|
+
uses: codecov/codecov-action@v5
|
|
162
162
|
with:
|
|
163
163
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
164
164
|
fail_ci_if_error: true
|
|
@@ -187,7 +187,7 @@ jobs:
|
|
|
187
187
|
- name: install Just
|
|
188
188
|
uses: taiki-e/install-action@just
|
|
189
189
|
- name: Install uv
|
|
190
|
-
uses: astral-sh/setup-uv@
|
|
190
|
+
uses: astral-sh/setup-uv@v5
|
|
191
191
|
with:
|
|
192
192
|
enable-cache: true
|
|
193
193
|
- name: Set up Python
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: meilisearch-python-sdk
|
|
3
|
-
Version:
|
|
3
|
+
Version: 4.0.0
|
|
4
4
|
Summary: A Python client providing both async and sync support for the Meilisearch API
|
|
5
5
|
Project-URL: repository, https://github.com/sanders41/meilisearch-python-sdk
|
|
6
6
|
Project-URL: homepage, https://github.com/sanders41/meilisearch-python-sdk
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
from meilisearch_python_sdk._utils import get_async_client, get_client
|
|
6
|
+
from meilisearch_python_sdk.errors import BatchNotFoundError
|
|
7
|
+
from meilisearch_python_sdk.models.batch import BatchResult, BatchStatus
|
|
8
|
+
|
|
9
|
+
if TYPE_CHECKING:
|
|
10
|
+
from httpx import AsyncClient as HttpxAsyncClient # pragma: no cover
|
|
11
|
+
from httpx import Client as HttpxClient # pragma: no cover
|
|
12
|
+
|
|
13
|
+
from meilisearch_python_sdk._client import ( # pragma: no cover
|
|
14
|
+
AsyncClient,
|
|
15
|
+
Client,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
async def async_get_batch(
|
|
20
|
+
client: HttpxAsyncClient | AsyncClient, batch_uid: int
|
|
21
|
+
) -> BatchResult | None:
|
|
22
|
+
client_ = get_async_client(client)
|
|
23
|
+
response = await client_.get(f"batches/{batch_uid}")
|
|
24
|
+
|
|
25
|
+
if response.status_code == 404:
|
|
26
|
+
raise BatchNotFoundError(f"Batch {batch_uid} not found")
|
|
27
|
+
|
|
28
|
+
return BatchResult(**response.json())
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
async def async_get_batches(client: HttpxAsyncClient | AsyncClient) -> BatchStatus:
|
|
32
|
+
client_ = get_async_client(client)
|
|
33
|
+
response = await client_.get("batches")
|
|
34
|
+
|
|
35
|
+
return BatchStatus(**response.json())
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def get_batch(client: HttpxClient | Client, batch_uid: int) -> BatchResult | None:
|
|
39
|
+
client_ = get_client(client)
|
|
40
|
+
response = client_.get(f"batches/{batch_uid}")
|
|
41
|
+
|
|
42
|
+
if response.status_code == 404:
|
|
43
|
+
raise BatchNotFoundError(f"Batch {batch_uid} not found")
|
|
44
|
+
|
|
45
|
+
return BatchResult(**response.json())
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def get_batches(client: HttpxClient | Client) -> BatchStatus:
|
|
49
|
+
client_ = get_client(client)
|
|
50
|
+
response = client_.get("batches")
|
|
51
|
+
|
|
52
|
+
return BatchStatus(**response.json())
|
{meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/meilisearch_python_sdk/_client.py
RENAMED
|
@@ -9,6 +9,7 @@ from httpx import AsyncClient as HttpxAsyncClient
|
|
|
9
9
|
from httpx import Client as HttpxClient
|
|
10
10
|
|
|
11
11
|
from meilisearch_python_sdk import _task
|
|
12
|
+
from meilisearch_python_sdk._batch import async_get_batch, async_get_batches, get_batch, get_batches
|
|
12
13
|
from meilisearch_python_sdk._http_requests import AsyncHttpRequests, HttpRequests
|
|
13
14
|
from meilisearch_python_sdk.errors import InvalidRestriction, MeilisearchApiError
|
|
14
15
|
from meilisearch_python_sdk.index import AsyncIndex, Index
|
|
@@ -39,6 +40,7 @@ if TYPE_CHECKING: # pragma: no cover
|
|
|
39
40
|
import sys
|
|
40
41
|
from types import TracebackType
|
|
41
42
|
|
|
43
|
+
from meilisearch_python_sdk.models.batch import BatchResult, BatchStatus
|
|
42
44
|
from meilisearch_python_sdk.types import JsonMapping
|
|
43
45
|
|
|
44
46
|
if sys.version_info >= (3, 11):
|
|
@@ -144,7 +146,7 @@ class AsyncClient(BaseClient):
|
|
|
144
146
|
api_key: str | None = None,
|
|
145
147
|
*,
|
|
146
148
|
timeout: int | None = None,
|
|
147
|
-
verify:
|
|
149
|
+
verify: bool | SSLContext = True,
|
|
148
150
|
custom_headers: dict[str, str] | None = None,
|
|
149
151
|
json_handler: BuiltinHandler | OrjsonHandler | UjsonHandler | None = None,
|
|
150
152
|
http2: bool = False,
|
|
@@ -770,6 +772,12 @@ class AsyncClient(BaseClient):
|
|
|
770
772
|
|
|
771
773
|
return TaskInfo(**response.json())
|
|
772
774
|
|
|
775
|
+
async def get_batch(self, batch_uid: int) -> BatchResult | None:
|
|
776
|
+
return await async_get_batch(self, batch_uid)
|
|
777
|
+
|
|
778
|
+
async def get_batches(self) -> BatchStatus:
|
|
779
|
+
return await async_get_batches(self)
|
|
780
|
+
|
|
773
781
|
async def cancel_tasks(
|
|
774
782
|
self,
|
|
775
783
|
*,
|
|
@@ -903,6 +911,7 @@ class AsyncClient(BaseClient):
|
|
|
903
911
|
*,
|
|
904
912
|
index_ids: list[str] | None = None,
|
|
905
913
|
types: str | list[str] | None = None,
|
|
914
|
+
reverse: bool | None = None,
|
|
906
915
|
) -> TaskStatus:
|
|
907
916
|
"""Get multiple tasks.
|
|
908
917
|
|
|
@@ -910,6 +919,7 @@ class AsyncClient(BaseClient):
|
|
|
910
919
|
index_ids: A list of index UIDs for which to get the tasks. If provided this will get the
|
|
911
920
|
tasks only for the specified indexes, if not all tasks will be returned. Default = None
|
|
912
921
|
types: Specify specific task types to retrieve. Default = None
|
|
922
|
+
reverse: If True the tasks will be returned in reverse order. Default = None
|
|
913
923
|
|
|
914
924
|
Returns:
|
|
915
925
|
Task statuses.
|
|
@@ -925,7 +935,9 @@ class AsyncClient(BaseClient):
|
|
|
925
935
|
>>> async with AsyncClient("http://localhost.com", "masterKey") as client:
|
|
926
936
|
>>> await client.get_tasks()
|
|
927
937
|
"""
|
|
928
|
-
return await _task.async_get_tasks(
|
|
938
|
+
return await _task.async_get_tasks(
|
|
939
|
+
self.http_client, index_ids=index_ids, types=types, reverse=reverse
|
|
940
|
+
)
|
|
929
941
|
|
|
930
942
|
async def wait_for_task(
|
|
931
943
|
self,
|
|
@@ -984,7 +996,7 @@ class Client(BaseClient):
|
|
|
984
996
|
api_key: str | None = None,
|
|
985
997
|
*,
|
|
986
998
|
timeout: int | None = None,
|
|
987
|
-
verify:
|
|
999
|
+
verify: bool | SSLContext = True,
|
|
988
1000
|
custom_headers: dict[str, str] | None = None,
|
|
989
1001
|
json_handler: BuiltinHandler | OrjsonHandler | UjsonHandler | None = None,
|
|
990
1002
|
http2: bool = False,
|
|
@@ -1586,6 +1598,12 @@ class Client(BaseClient):
|
|
|
1586
1598
|
|
|
1587
1599
|
return TaskInfo(**response.json())
|
|
1588
1600
|
|
|
1601
|
+
def get_batch(self, batch_uid: int) -> BatchResult | None:
|
|
1602
|
+
return get_batch(self, batch_uid)
|
|
1603
|
+
|
|
1604
|
+
def get_batches(self) -> BatchStatus:
|
|
1605
|
+
return get_batches(self)
|
|
1606
|
+
|
|
1589
1607
|
def cancel_tasks(
|
|
1590
1608
|
self,
|
|
1591
1609
|
*,
|
|
@@ -1718,6 +1736,7 @@ class Client(BaseClient):
|
|
|
1718
1736
|
*,
|
|
1719
1737
|
index_ids: list[str] | None = None,
|
|
1720
1738
|
types: str | list[str] | None = None,
|
|
1739
|
+
reverse: bool | None = None,
|
|
1721
1740
|
) -> TaskStatus:
|
|
1722
1741
|
"""Get multiple tasks.
|
|
1723
1742
|
|
|
@@ -1725,6 +1744,7 @@ class Client(BaseClient):
|
|
|
1725
1744
|
index_ids: A list of index UIDs for which to get the tasks. If provided this will get the
|
|
1726
1745
|
tasks only for the specified indexes, if not all tasks will be returned. Default = None
|
|
1727
1746
|
types: Specify specific task types to retrieve. Default = None
|
|
1747
|
+
reverse: If True the tasks will be returned in reverse order. Default = None
|
|
1728
1748
|
|
|
1729
1749
|
Returns:
|
|
1730
1750
|
Task statuses.
|
|
@@ -1740,7 +1760,7 @@ class Client(BaseClient):
|
|
|
1740
1760
|
>>> client = Client("http://localhost.com", "masterKey")
|
|
1741
1761
|
>>> client.get_tasks(client)
|
|
1742
1762
|
"""
|
|
1743
|
-
return _task.get_tasks(self.http_client, index_ids=index_ids, types=types)
|
|
1763
|
+
return _task.get_tasks(self.http_client, index_ids=index_ids, types=types, reverse=reverse)
|
|
1744
1764
|
|
|
1745
1765
|
def wait_for_task(
|
|
1746
1766
|
self,
|
|
@@ -116,12 +116,12 @@ class HttpRequests:
|
|
|
116
116
|
http_method: Callable,
|
|
117
117
|
path: str,
|
|
118
118
|
body: Any | None = None,
|
|
119
|
-
content_type: str = "
|
|
119
|
+
content_type: str = "application/json",
|
|
120
120
|
compress: bool = False,
|
|
121
121
|
) -> Response:
|
|
122
122
|
headers = build_headers(content_type, compress)
|
|
123
123
|
try:
|
|
124
|
-
if
|
|
124
|
+
if body is None:
|
|
125
125
|
response = http_method(path)
|
|
126
126
|
elif content_type == "application/json" and not compress:
|
|
127
127
|
response = http_method(path, content=self.json_handler.dumps(body), headers=headers)
|
{meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/meilisearch_python_sdk/_task.py
RENAMED
|
@@ -10,6 +10,7 @@ from httpx import AsyncClient as HttpxAsyncClient
|
|
|
10
10
|
from httpx import Client as HttpxClient
|
|
11
11
|
|
|
12
12
|
from meilisearch_python_sdk._http_requests import AsyncHttpRequests, HttpRequests
|
|
13
|
+
from meilisearch_python_sdk._utils import get_async_client, get_client
|
|
13
14
|
from meilisearch_python_sdk.errors import MeilisearchTaskFailedError, MeilisearchTimeoutError
|
|
14
15
|
from meilisearch_python_sdk.json_handler import BuiltinHandler, OrjsonHandler, UjsonHandler
|
|
15
16
|
from meilisearch_python_sdk.models.task import TaskInfo, TaskResult, TaskStatus
|
|
@@ -76,7 +77,7 @@ async def async_cancel_tasks(
|
|
|
76
77
|
parameters["statuses"] = "enqueued,processing"
|
|
77
78
|
|
|
78
79
|
url = f"tasks/cancel?{urlencode(parameters)}"
|
|
79
|
-
client_ =
|
|
80
|
+
client_ = get_async_client(client)
|
|
80
81
|
response = await client_.post(url)
|
|
81
82
|
|
|
82
83
|
return TaskInfo(**response.json())
|
|
@@ -110,14 +111,17 @@ async def async_delete_tasks(
|
|
|
110
111
|
parameters["statuses"] = "canceled,enqueued,failed,processing,succeeded"
|
|
111
112
|
|
|
112
113
|
url = f"tasks?{urlencode(parameters)}"
|
|
113
|
-
client_ =
|
|
114
|
+
client_ = get_async_client(client)
|
|
114
115
|
response = await client_.delete(url)
|
|
115
116
|
|
|
116
117
|
return TaskInfo(**response.json())
|
|
117
118
|
|
|
118
119
|
|
|
119
|
-
async def async_get_task(
|
|
120
|
-
|
|
120
|
+
async def async_get_task(
|
|
121
|
+
client: HttpxAsyncClient | AsyncClient,
|
|
122
|
+
task_id: int,
|
|
123
|
+
) -> TaskResult:
|
|
124
|
+
client_ = get_async_client(client)
|
|
121
125
|
response = await client_.get(f"tasks/{task_id}")
|
|
122
126
|
|
|
123
127
|
return TaskResult(**response.json())
|
|
@@ -128,12 +132,19 @@ async def async_get_tasks(
|
|
|
128
132
|
*,
|
|
129
133
|
index_ids: list[str] | None = None,
|
|
130
134
|
types: str | list[str] | None = None,
|
|
135
|
+
reverse: bool | None = None,
|
|
131
136
|
) -> TaskStatus:
|
|
132
137
|
url = f"tasks?indexUids={','.join(index_ids)}" if index_ids else "tasks"
|
|
133
138
|
if types:
|
|
134
139
|
formatted_types = ",".join(types) if isinstance(types, list) else types
|
|
135
140
|
url = f"{url}&types={formatted_types}" if "?" in url else f"{url}?types={formatted_types}"
|
|
136
|
-
|
|
141
|
+
if reverse:
|
|
142
|
+
url = (
|
|
143
|
+
f"{url}&reverse={str(reverse).lower()}"
|
|
144
|
+
if "?" in url
|
|
145
|
+
else f"{url}?reverse={str(reverse).lower()}"
|
|
146
|
+
)
|
|
147
|
+
client_ = get_async_client(client)
|
|
137
148
|
response = await client_.get(url)
|
|
138
149
|
|
|
139
150
|
return TaskStatus(**response.json())
|
|
@@ -147,7 +158,7 @@ async def async_wait_for_task(
|
|
|
147
158
|
interval_in_ms: int = 50,
|
|
148
159
|
raise_for_status: bool = False,
|
|
149
160
|
) -> TaskResult:
|
|
150
|
-
client_ =
|
|
161
|
+
client_ = get_async_client(client)
|
|
151
162
|
handler = _get_json_handler(client)
|
|
152
163
|
url = f"tasks/{task_id}"
|
|
153
164
|
http_requests = AsyncHttpRequests(client_, handler)
|
|
@@ -207,7 +218,7 @@ def cancel_tasks(
|
|
|
207
218
|
parameters["statuses"] = "enqueued,processing"
|
|
208
219
|
|
|
209
220
|
url = f"tasks/cancel?{urlencode(parameters)}"
|
|
210
|
-
client_ =
|
|
221
|
+
client_ = get_client(client)
|
|
211
222
|
response = client_.post(url)
|
|
212
223
|
|
|
213
224
|
return TaskInfo(**response.json())
|
|
@@ -241,14 +252,14 @@ def delete_tasks(
|
|
|
241
252
|
parameters["statuses"] = "canceled,enqueued,failed,processing,succeeded"
|
|
242
253
|
|
|
243
254
|
url = f"tasks?{urlencode(parameters)}"
|
|
244
|
-
client_ =
|
|
255
|
+
client_ = get_client(client)
|
|
245
256
|
response = client_.delete(url)
|
|
246
257
|
|
|
247
258
|
return TaskInfo(**response.json())
|
|
248
259
|
|
|
249
260
|
|
|
250
261
|
def get_task(client: HttpxClient | Client, task_id: int) -> TaskResult:
|
|
251
|
-
client_ =
|
|
262
|
+
client_ = get_client(client)
|
|
252
263
|
response = client_.get(f"tasks/{task_id}")
|
|
253
264
|
|
|
254
265
|
return TaskResult(**response.json())
|
|
@@ -259,12 +270,19 @@ def get_tasks(
|
|
|
259
270
|
*,
|
|
260
271
|
index_ids: list[str] | None = None,
|
|
261
272
|
types: str | list[str] | None = None,
|
|
273
|
+
reverse: bool | None = None,
|
|
262
274
|
) -> TaskStatus:
|
|
263
275
|
url = f"tasks?indexUids={','.join(index_ids)}" if index_ids else "tasks"
|
|
264
276
|
if types:
|
|
265
277
|
formatted_types = ",".join(types) if isinstance(types, list) else types
|
|
266
278
|
url = f"{url}&types={formatted_types}" if "?" in url else f"{url}?types={formatted_types}"
|
|
267
|
-
|
|
279
|
+
if reverse:
|
|
280
|
+
url = (
|
|
281
|
+
f"{url}&reverse={str(reverse).lower()}"
|
|
282
|
+
if "?" in url
|
|
283
|
+
else f"{url}?reverse={str(reverse).lower()}"
|
|
284
|
+
)
|
|
285
|
+
client_ = get_client(client)
|
|
268
286
|
response = client_.get(url)
|
|
269
287
|
|
|
270
288
|
return TaskStatus(**response.json())
|
|
@@ -278,7 +296,7 @@ def wait_for_task(
|
|
|
278
296
|
interval_in_ms: int = 50,
|
|
279
297
|
raise_for_status: bool = False,
|
|
280
298
|
) -> TaskResult:
|
|
281
|
-
client_ =
|
|
299
|
+
client_ = get_client(client)
|
|
282
300
|
handler = _get_json_handler(client)
|
|
283
301
|
url = f"tasks/{task_id}"
|
|
284
302
|
http_requests = HttpRequests(client_, json_handler=handler)
|
|
@@ -310,24 +328,6 @@ def wait_for_task(
|
|
|
310
328
|
time.sleep(interval_in_ms / 1000)
|
|
311
329
|
|
|
312
330
|
|
|
313
|
-
def _get_async_client(
|
|
314
|
-
client: AsyncClient | HttpxAsyncClient,
|
|
315
|
-
) -> HttpxAsyncClient:
|
|
316
|
-
if isinstance(client, HttpxAsyncClient):
|
|
317
|
-
return client
|
|
318
|
-
|
|
319
|
-
return client.http_client
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
def _get_client(
|
|
323
|
-
client: Client | HttpxClient,
|
|
324
|
-
) -> HttpxClient:
|
|
325
|
-
if isinstance(client, HttpxClient):
|
|
326
|
-
return client
|
|
327
|
-
|
|
328
|
-
return client.http_client
|
|
329
|
-
|
|
330
|
-
|
|
331
331
|
def _get_json_handler(
|
|
332
332
|
client: AsyncClient | Client | HttpxAsyncClient | HttpxClient,
|
|
333
333
|
) -> BuiltinHandler | OrjsonHandler | UjsonHandler:
|
{meilisearch_python_sdk-3.6.1 → meilisearch_python_sdk-4.0.0}/meilisearch_python_sdk/_utils.py
RENAMED
|
@@ -3,6 +3,31 @@ from __future__ import annotations
|
|
|
3
3
|
import sys
|
|
4
4
|
from datetime import datetime
|
|
5
5
|
from functools import lru_cache
|
|
6
|
+
from typing import TYPE_CHECKING
|
|
7
|
+
|
|
8
|
+
from httpx import AsyncClient as HttpxAsyncClient
|
|
9
|
+
from httpx import Client as HttpxClient
|
|
10
|
+
|
|
11
|
+
if TYPE_CHECKING:
|
|
12
|
+
from meilisearch_python_sdk._client import AsyncClient, Client # pragma: no cover
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def get_async_client(
|
|
16
|
+
client: AsyncClient | HttpxAsyncClient,
|
|
17
|
+
) -> HttpxAsyncClient:
|
|
18
|
+
if isinstance(client, HttpxAsyncClient):
|
|
19
|
+
return client
|
|
20
|
+
|
|
21
|
+
return client.http_client
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def get_client(
|
|
25
|
+
client: Client | HttpxClient,
|
|
26
|
+
) -> HttpxClient:
|
|
27
|
+
if isinstance(client, HttpxClient):
|
|
28
|
+
return client
|
|
29
|
+
|
|
30
|
+
return client.http_client
|
|
6
31
|
|
|
7
32
|
|
|
8
33
|
def iso_to_date_time(iso_date: datetime | str | None) -> datetime | None:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VERSION = "4.0.0"
|