-
Notifications
You must be signed in to change notification settings - Fork 999
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Francisco Javier Arceo <[email protected]>
- Loading branch information
1 parent
12604e5
commit 1073ec5
Showing
3 changed files
with
171 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
sdk/python/tests/integration/feature_repos/universal/online_store/milvus.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import os | ||
import time | ||
from typing import Any, Dict | ||
|
||
from pymilvus import connections | ||
from testcontainers.core.container import DockerContainer | ||
|
||
from tests.integration.feature_repos.universal.online_store_creator import ( | ||
OnlineStoreCreator, | ||
) | ||
|
||
|
||
class MilvusOnlineStoreCreator(OnlineStoreCreator): | ||
def __init__(self, project_name: str, **kwargs): | ||
super().__init__(project_name) | ||
self.container = DockerContainer("milvusdb/milvus:v2.2.9").with_exposed_ports(19530) | ||
|
||
def create_online_store(self) -> Dict[str, Any]: | ||
self.container.start() | ||
# Wait for Milvus server to be ready | ||
host = "localhost" | ||
port = self.container.get_exposed_port(19530) | ||
|
||
max_attempts = 12 | ||
for attempt in range(1, max_attempts + 1): | ||
try: | ||
print(f"Attempting to connect to Milvus at {host}:{port}, attempt {attempt}") | ||
connections.connect(alias='default', host=host, port=port) | ||
if connections.has_connection(alias='default'): | ||
print("Successfully connected to Milvus") | ||
break | ||
except Exception as e: | ||
print(f"Connection attempt failed: {e}") | ||
time.sleep(5) | ||
else: | ||
raise RuntimeError("Cannot connect to Milvus server after multiple attempts") | ||
|
||
return { | ||
"type": "milvus", | ||
"host": host, | ||
"port": int(port), | ||
"index_type": "IVF_FLAT", | ||
"metric_type": "L2", | ||
"embedding_dim": 128, # Adjust based on your embedding dimension | ||
"vector_enabled": True, | ||
} | ||
|
||
def teardown(self): | ||
self.container.stop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters