Skip to content

Commit caffc26

Browse files
committed
feat: Adding support Multimodal embedders.
1 parent 887a7e3 commit caffc26

File tree

1 file changed

+11
-20
lines changed

1 file changed

+11
-20
lines changed

tests/client/test_multimodal.py

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
import pytest
77
import requests
8+
89
from meilisearch import Client
10+
from meilisearch.errors import MeilisearchApiError
911
from tests import common
1012

1113
# ---------------- ENV ----------------
@@ -146,7 +148,8 @@ def clear_indexes(self, client):
146148
try:
147149
task = client.index(index.uid).delete()
148150
client.wait_for_task(task.task_uid)
149-
except Exception:
151+
except (MeilisearchApiError, Exception): # pylint: disable=broad-exception-caught
152+
# Ignore errors when deleting indexes (may not exist)
150153
pass
151154

152155
@pytest.fixture(scope="class", autouse=True)
@@ -161,7 +164,7 @@ def setup_index(self, request):
161164
try:
162165
task = client.index(INDEX_UID).delete()
163166
client.wait_for_task(task.task_uid)
164-
except Exception:
167+
except MeilisearchApiError:
165168
pass # Index doesn't exist, which is fine
166169

167170
# Create index
@@ -185,38 +188,26 @@ def setup_index(self, request):
185188
"Content-Type": "application/json",
186189
},
187190
json=settings_payload,
191+
timeout=30,
188192
)
189193
response.raise_for_status()
190194

191195
# Wait for settings update task (embedder config can take longer)
192196
task_data = response.json()
193197
task_uid = task_data.get("taskUid")
194-
if task_uid:
195-
task = client.wait_for_task(
196-
task_uid, timeout_in_ms=60_000
197-
) # 1 minute for embedder setup
198-
if task.status != "succeeded":
199-
error_msg = f"Embedder setup failed: status={task.status}"
200-
if task.error:
201-
error_msg += f", error={task.error}"
202-
raise Exception(error_msg)
198+
client.wait_for_task(task_uid, timeout_in_ms=60_000)
203199

204200
index = client.get_index(INDEX_UID)
205201

206202
# Add documents
207203
task = index.add_documents(MOVIES)
208204
# Use longer timeout for document indexing with embeddings
209205
# Each document needs embeddings generated via Voyage API, which can be slow
210-
task = client.wait_for_task(
206+
client.wait_for_task(
211207
task.task_uid,
212208
timeout_in_ms=300_000, # 5 minutes timeout for embedding generation
213209
interval_in_ms=1000, # Poll every 1 second instead of 50ms to reduce log noise
214210
)
215-
if task.status != "succeeded":
216-
error_msg = f"Document indexing failed: status={task.status}"
217-
if task.error:
218-
error_msg += f", error={task.error}"
219-
raise Exception(error_msg)
220211

221212
# Verify index is ready by checking stats
222213
stats = index.get_stats()
@@ -229,7 +220,7 @@ def setup_index(self, request):
229220
request.cls.index = index
230221
request.cls.search_client = Client(common.BASE_URL, common.MASTER_KEY) # Search client
231222

232-
def test_text_query(self):
223+
def test_text_query(self): # pylint: disable=no-member
233224
"""Test text query search"""
234225
query = "The story follows Carol Danvers"
235226
response = self.search_client.index(INDEX_UID).search(
@@ -248,7 +239,7 @@ def test_text_query(self):
248239
)
249240
assert response["hits"][0]["title"] == "Captain Marvel"
250241

251-
def test_image_query(self):
242+
def test_image_query(self): # pylint: disable=no-member
252243
"""Test image query search"""
253244
# Find Dumbo in the movies list
254245
dumbo_movie = next(m for m in MOVIES if m["title"] == "Dumbo")
@@ -270,7 +261,7 @@ def test_image_query(self):
270261
)
271262
assert response["hits"][0]["title"] == "Dumbo"
272263

273-
def test_text_and_image_query(self):
264+
def test_text_and_image_query(self): # pylint: disable=no-member
274265
"""Test text and image query"""
275266
query = "a futuristic movie"
276267
master_yoda_base64 = load_image_base64("master-yoda.jpeg")

0 commit comments

Comments
 (0)