Skip to content

Commit 83c25b4

Browse files
authored
Merge branch 'main' into meili-bot/feb-23-code-samples
2 parents 4a7885b + 7bfbe09 commit 83c25b4

18 files changed

+414
-415
lines changed

.github/workflows/pypi-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
deploy:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v2
12+
- uses: actions/checkout@v3
1313
- name: Set up Python
1414
uses: actions/setup-python@v4
1515
with:

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ jobs:
8989
steps:
9090
- uses: actions/checkout@v3
9191
- name: Set up Python 3.9
92-
uses: actions/setup-python@v2
92+
uses: actions/setup-python@v4
9393
with:
9494
python-version: 3.9
9595
- name: Install pipenv
9696
uses: dschep/install-pipenv-action@v1
9797
- name: Install dependencies
9898
run: pipenv install --dev --python=${{ matrix.python-version }}
9999
- name: isort
100-
run: pipenv run isort meilisearch tests setup.py --check-only
100+
run: pipenv run isort meilisearch tests --check-only

Pipfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ types-requests = "*"
1515
black = "*"
1616
isort = "*"
1717
importlib_metadata = {version = "*", markers="python_version < '3.8'"}
18-
zipp = {version = "==3.14.0", markers="python_version < '3.8'"}
18+
zipp = {version = "==3.15.0", markers="python_version < '3.8'"}
1919
exceptiongroup = {version = "*", markers="python_version < '3.11'"}
2020
tomli = {version = "*", markers="python_version < '3.11'"}
2121
wrapt = {version = "*", markers="python_version < '3.11'"}

Pipfile.lock

Lines changed: 274 additions & 275 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

meilisearch/_httprequests.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
from meilisearch.config import Config
99
from meilisearch.errors import (
10-
MeiliSearchApiError,
11-
MeiliSearchCommunicationError,
12-
MeiliSearchTimeoutError,
10+
MeilisearchApiError,
11+
MeilisearchCommunicationError,
12+
MeilisearchTimeoutError,
1313
)
1414
from meilisearch.version import qualified_version
1515

@@ -50,9 +50,9 @@ def send_request(
5050
return self.__validate(request)
5151

5252
except requests.exceptions.Timeout as err:
53-
raise MeiliSearchTimeoutError(str(err)) from err
53+
raise MeilisearchTimeoutError(str(err)) from err
5454
except requests.exceptions.ConnectionError as err:
55-
raise MeiliSearchCommunicationError(str(err)) from err
55+
raise MeilisearchCommunicationError(str(err)) from err
5656

5757
def get(self, path: str) -> Any:
5858
return self.send_request(requests.get, path)
@@ -100,4 +100,4 @@ def __validate(request: requests.Response) -> Any:
100100
request.raise_for_status()
101101
return HttpRequests.__to_json(request)
102102
except requests.exceptions.HTTPError as err:
103-
raise MeiliSearchApiError(str(err), request) from err
103+
raise MeilisearchApiError(str(err), request) from err

meilisearch/client.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from meilisearch._httprequests import HttpRequests
1313
from meilisearch.config import Config
14-
from meilisearch.errors import MeiliSearchError
14+
from meilisearch.errors import MeilisearchError
1515
from meilisearch.index import Index
1616
from meilisearch.models.key import Key, KeysResults
1717
from meilisearch.models.task import TaskInfo
@@ -61,7 +61,7 @@ def create_index(self, uid: str, options: Optional[Dict[str, Any]] = None) -> Ta
6161
6262
Raises
6363
------
64-
MeiliSearchApiError
64+
MeilisearchApiError
6565
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
6666
"""
6767
return Index.create(self.config, uid, options)
@@ -82,7 +82,7 @@ def delete_index(self, uid: str) -> TaskInfo:
8282
8383
Raises
8484
------
85-
MeiliSearchApiError
85+
MeilisearchApiError
8686
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
8787
"""
8888

@@ -105,7 +105,7 @@ def get_indexes(self, parameters: Optional[Dict[str, Any]] = None) -> Dict[str,
105105
106106
Raises
107107
------
108-
MeiliSearchApiError
108+
MeilisearchApiError
109109
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
110110
"""
111111
if parameters is None:
@@ -138,7 +138,7 @@ def get_raw_indexes(self, parameters: Optional[Dict[str, Any]] = None) -> List[D
138138
139139
Raises
140140
------
141-
MeiliSearchApiError
141+
MeilisearchApiError
142142
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
143143
"""
144144
if parameters is None:
@@ -161,7 +161,7 @@ def get_index(self, uid: str) -> Index:
161161
162162
Raises
163163
------
164-
MeiliSearchApiError
164+
MeilisearchApiError
165165
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
166166
"""
167167
return Index(self.config, uid).fetch_info()
@@ -182,7 +182,7 @@ def get_raw_index(self, uid: str) -> Dict[str, Any]:
182182
183183
Raises
184184
------
185-
MeiliSearchApiError
185+
MeilisearchApiError
186186
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
187187
"""
188188
return self.http.get(f"{self.config.paths.index}/{uid}")
@@ -218,7 +218,7 @@ def get_all_stats(self) -> Dict[str, Any]:
218218
219219
Raises
220220
------
221-
MeiliSearchApiError
221+
MeilisearchApiError
222222
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
223223
"""
224224
return self.http.get(self.config.paths.stat)
@@ -233,7 +233,7 @@ def health(self) -> Dict[str, str]:
233233
234234
Raises
235235
------
236-
MeiliSearchApiError
236+
MeilisearchApiError
237237
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
238238
"""
239239
return self.http.get(self.config.paths.health)
@@ -242,7 +242,7 @@ def is_healthy(self) -> bool:
242242
"""Get health of the Meilisearch server."""
243243
try:
244244
self.health()
245-
except MeiliSearchError:
245+
except MeilisearchError:
246246
return False
247247
return True
248248

@@ -262,7 +262,7 @@ def get_key(self, key_or_uid: str) -> Key:
262262
263263
Raises
264264
------
265-
MeiliSearchApiError
265+
MeilisearchApiError
266266
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
267267
"""
268268
key = self.http.get(f"{self.config.paths.keys}/{key_or_uid}")
@@ -285,7 +285,7 @@ def get_keys(self, parameters: Optional[Dict[str, Any]] = None) -> KeysResults:
285285
286286
Raises
287287
------
288-
MeiliSearchApiError
288+
MeilisearchApiError
289289
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
290290
"""
291291
if parameters is None:
@@ -314,7 +314,7 @@ def create_key(self, options: Dict[str, Any]) -> Key:
314314
315315
Raises
316316
------
317-
MeiliSearchApiError
317+
MeilisearchApiError
318318
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
319319
"""
320320
task = self.http.post(f"{self.config.paths.keys}", options)
@@ -340,7 +340,7 @@ def update_key(self, key_or_uid: str, options: Dict[str, Any]) -> Key:
340340
341341
Raises
342342
------
343-
MeiliSearchApiError
343+
MeilisearchApiError
344344
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
345345
"""
346346
url = f"{self.config.paths.keys}/{key_or_uid}"
@@ -364,7 +364,7 @@ def delete_key(self, key_or_uid: str) -> int:
364364
365365
Raises
366366
------
367-
MeiliSearchApiError
367+
MeilisearchApiError
368368
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
369369
"""
370370
response = self.http.delete(f"{self.config.paths.keys}/{key_or_uid}")
@@ -381,7 +381,7 @@ def get_version(self) -> Dict[str, str]:
381381
382382
Raises
383383
------
384-
MeiliSearchApiError
384+
MeilisearchApiError
385385
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
386386
"""
387387
return self.http.get(self.config.paths.version)
@@ -396,7 +396,7 @@ def version(self) -> Dict[str, str]:
396396
397397
Raises
398398
------
399-
MeiliSearchApiError
399+
MeilisearchApiError
400400
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
401401
"""
402402
return self.get_version()
@@ -412,7 +412,7 @@ def create_dump(self) -> TaskInfo:
412412
413413
Raises
414414
------
415-
MeiliSearchApiError
415+
MeilisearchApiError
416416
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
417417
"""
418418
task = self.http.post(self.config.paths.dumps)
@@ -435,7 +435,7 @@ def swap_indexes(self, parameters: List[Dict[str, List[str]]]) -> TaskInfo:
435435
436436
Raises
437437
------
438-
MeiliSearchApiError
438+
MeilisearchApiError
439439
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
440440
"""
441441
return TaskInfo(**self.http.post(self.config.paths.swap, parameters))
@@ -457,7 +457,7 @@ def get_tasks(
457457
458458
Raises
459459
------
460-
MeiliSearchApiError
460+
MeilisearchApiError
461461
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
462462
"""
463463
return self.task_handler.get_tasks(parameters=parameters)
@@ -477,7 +477,7 @@ def get_task(self, uid: int) -> Dict[str, Any]:
477477
478478
Raises
479479
------
480-
MeiliSearchApiError
480+
MeilisearchApiError
481481
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
482482
"""
483483
return self.task_handler.get_task(uid)
@@ -498,7 +498,7 @@ def cancel_tasks(self, parameters: Dict[str, Any]) -> TaskInfo:
498498
499499
Raises
500500
------
501-
MeiliSearchApiError
501+
MeilisearchApiError
502502
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
503503
"""
504504
return self.task_handler.cancel_tasks(parameters=parameters)
@@ -517,7 +517,7 @@ def delete_tasks(self, parameters: Dict[str, Any]) -> TaskInfo:
517517
https://docs.meilisearch.com/reference/api/tasks.html#get-one-task
518518
Raises
519519
------
520-
MeiliSearchApiError
520+
MeilisearchApiError
521521
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
522522
"""
523523
return self.task_handler.delete_tasks(parameters=parameters)
@@ -535,7 +535,7 @@ def wait_for_task(
535535
uid:
536536
Identifier of the task to wait for being processed.
537537
timeout_in_ms (optional):
538-
Time the method should wait before raising a MeiliSearchTimeoutError
538+
Time the method should wait before raising a MeilisearchTimeoutError
539539
interval_in_ms (optional):
540540
Time interval the method should wait (sleep) between requests
541541
@@ -546,7 +546,7 @@ def wait_for_task(
546546
547547
Raises
548548
------
549-
MeiliSearchTimeoutError
549+
MeilisearchTimeoutError
550550
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
551551
"""
552552
return self.task_handler.wait_for_task(uid, timeout_in_ms, interval_in_ms)

meilisearch/errors.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55
from requests import Response
66

77

8-
class MeiliSearchError(Exception):
8+
class MeilisearchError(Exception):
99
"""Generic class for Meilisearch error handling"""
1010

1111
def __init__(self, message: str) -> None:
1212
self.message = message
1313
super().__init__(self.message)
1414

1515
def __str__(self) -> str:
16-
return f"MeiliSearchError. Error message: {self.message}"
16+
return f"MeilisearchError. Error message: {self.message}"
1717

1818

19-
class MeiliSearchApiError(MeiliSearchError):
19+
class MeilisearchApiError(MeilisearchError):
2020
"""Error sent by Meilisearch API"""
2121

2222
def __init__(self, error: str, request: Response) -> None:
@@ -37,20 +37,20 @@ def __init__(self, error: str, request: Response) -> None:
3737

3838
def __str__(self) -> str:
3939
if self.code and self.link:
40-
return f"MeiliSearchApiError. Error code: {self.code}. Error message: {self.message} Error documentation: {self.link} Error type: {self.type}"
40+
return f"MeilisearchApiError. Error code: {self.code}. Error message: {self.message} Error documentation: {self.link} Error type: {self.type}"
4141

42-
return f"MeiliSearchApiError. {self.message}"
42+
return f"MeilisearchApiError. {self.message}"
4343

4444

45-
class MeiliSearchCommunicationError(MeiliSearchError):
45+
class MeilisearchCommunicationError(MeilisearchError):
4646
"""Error when connecting to Meilisearch"""
4747

4848
def __str__(self) -> str:
49-
return f"MeiliSearchCommunicationError, {self.message}"
49+
return f"MeilisearchCommunicationError, {self.message}"
5050

5151

52-
class MeiliSearchTimeoutError(MeiliSearchError):
52+
class MeilisearchTimeoutError(MeilisearchError):
5353
"""Error when Meilisearch operation takes longer than expected"""
5454

5555
def __str__(self) -> str:
56-
return f"MeiliSearchTimeoutError, {self.message}"
56+
return f"MeilisearchTimeoutError, {self.message}"

0 commit comments

Comments
 (0)