Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for meilisearch-python-sdk 2.0.0 #20

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from meilisearch_python_async import Client
from meilisearch_python_sdk import AsyncClient

client = Client(
client = AsyncClient(
"http://localhost:7700",
)
19 changes: 9 additions & 10 deletions meilisync/meili.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
from typing import AsyncGenerator, List, Optional, Type, Union

from loguru import logger
from meilisearch_python_async import Client
from meilisearch_python_async.errors import MeilisearchApiError
from meilisearch_python_async.task import wait_for_task
from meilisearch_python_sdk import AsyncClient
from meilisearch_python_sdk.errors import MeilisearchApiError

from meilisync.enums import EventType
from meilisync.event import EventCollection
Expand All @@ -21,7 +20,7 @@ def __init__(
plugins: Optional[List[Union[Type[Plugin], Plugin]]] = None,
wait_for_task_timeout: Optional[int] = None,
):
self.client = Client(
self.client = AsyncClient(
api_url,
api_key,
)
Expand All @@ -48,22 +47,22 @@ async def refresh_data(self, index: str, pk: str, data: AsyncGenerator):
index_tmp = await self.client.create_index(index_name_tmp, primary_key=pk)
task = await index_tmp.update_settings(settings)
logger.info(f"Waiting for update tmp index {index_name_tmp} settings to complete...")
await wait_for_task(
client=self.client, task_id=task.task_uid, timeout_in_ms=self.wait_for_task_timeout
await self.client.wait_for_task(
task_id=task.task_uid, timeout_in_ms=self.wait_for_task_timeout
)
tasks, count = await self.add_full_data(index_name_tmp, pk, data)
wait_tasks = [
wait_for_task(
client=self.client, task_id=item.task_uid, timeout_in_ms=self.wait_for_task_timeout
self.client.wait_for_task(
task_id=item.task_uid, timeout_in_ms=self.wait_for_task_timeout
)
for item in tasks
]
logger.info(f"Waiting for insert tmp index {index_name_tmp} to complete...")
await asyncio.gather(*wait_tasks)
task = await self.client.swap_indexes([(index, index_name_tmp)])
logger.info(f"Waiting for swap index {index} to complete...")
await wait_for_task(
client=self.client, task_id=task.task_uid, timeout_in_ms=self.wait_for_task_timeout
await self.client.wait_for_task(
task_id=task.task_uid, timeout_in_ms=self.wait_for_task_timeout
)
await self.client.index(index_name_tmp).delete()
logger.success(f"Swap index {index} complete")
Expand Down
Loading