Skip to content

Commit

Permalink
Delete flaky tests (#256)
Browse files Browse the repository at this point in the history
  • Loading branch information
wanliAlex authored Sep 13, 2024
1 parent cba2a33 commit 8035382
Showing 1 changed file with 1 addition and 70 deletions.
71 changes: 1 addition & 70 deletions tests/v2_tests/test_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,73 +184,4 @@ def test_embed_non_numeric_weight_fails(self):
with self.assertRaises(MarqoWebError) as e:
self.client.index(test_index_name).embed(content={"text to embed": "not a number"})

self.assertIn("not a valid float", str(e.exception))

def test_embed_images_with_languagebind(self):
"""Embeds multiple images using LanguageBind model."""
for cloud_test_index_to_use, open_source_test_index_name in self.test_cases_multimodal:
if "languagebind" not in str(cloud_test_index_to_use):
continue
test_index_name = self.get_test_index_name(
cloud_test_index_to_use=cloud_test_index_to_use,
open_source_test_index_name=open_source_test_index_name
)

with self.subTest(test_index_name):
image_urls = [
"https://raw.githubusercontent.com/marqo-ai/marqo-api-tests/mainline/assets/ai_hippo_realistic.png",
"https://raw.githubusercontent.com/marqo-ai/marqo-api-tests/mainline/assets/ai_hippo_realistic.png",
]

embed_res = self.client.index(test_index_name).embed(content=image_urls)

self.assertIn("processingTimeMs", embed_res)
self.assertEqual(embed_res["content"], image_urls)
self.assertEqual(len(embed_res["embeddings"]), 2)

# Check that embeddings are non-zero and have the expected shape
for embedding in embed_res["embeddings"]:
self.assertGreater(len(embedding), 0)
self.assertTrue(any(abs(x) > 1e-6 for x in embedding))

# Check that embeddings are close to the expected values
expected_embedding = [0.019889963790774345, -0.01263524405658245,
0.026028314605355263, 0.005291664972901344, -0.013181567192077637]
for embedding in embed_res["embeddings"]:
for i, value in enumerate(expected_embedding):
self.assertAlmostEqual(embedding[i], value, places=5)


def test_embed_videos_with_languagebind(self):
"""Embeds multiple videos using LanguageBind model."""
for cloud_test_index_to_use, open_source_test_index_name in self.test_cases_multimodal:
if "languagebind" not in str(cloud_test_index_to_use):
continue
test_index_name = self.get_test_index_name(
cloud_test_index_to_use=cloud_test_index_to_use,
open_source_test_index_name=open_source_test_index_name
)

with self.subTest(test_index_name):
video_urls = [
"https://marqo-k400-video-test-dataset.s3.amazonaws.com/videos/---QUuC4vJs_000084_000094.mp4",
"https://marqo-k400-video-test-dataset.s3.amazonaws.com/videos/---QUuC4vJs_000084_000094.mp4",
]

embed_res = self.client.index(test_index_name).embed(content=video_urls)

self.assertIn("processingTimeMs", embed_res)
self.assertEqual(embed_res["content"], video_urls)
self.assertEqual(len(embed_res["embeddings"]), 2)

# Check that embeddings are non-zero and have the expected shape
for embedding in embed_res["embeddings"]:
self.assertGreater(len(embedding), 0)
self.assertTrue(any(abs(x) > 1e-6 for x in embedding))

# Check that embeddings are close to the expected values
expected_embedding = [0.0298048947006464, 0.05226955562829971,
-0.0038126774597913027, 0.061151087284088135, -0.013925471343100071]
for embedding in embed_res["embeddings"]:
for i, value in enumerate(expected_embedding):
self.assertAlmostEqual(embedding[i], value, places=5)
self.assertIn("not a valid float", str(e.exception))

0 comments on commit 8035382

Please sign in to comment.