Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ class MilvusOnlineStoreConfig(FeastConfigBaseModel, VectorStoreConfig):
"""

type: Literal["milvus"] = "milvus"
path: Optional[StrictStr] = "online_store.db"
host: Optional[StrictStr] = "localhost"
path: Optional[StrictStr] = ""
host: Optional[StrictStr] = "http://localhost"
port: Optional[int] = 19530
index_type: Optional[str] = "FLAT"
metric_type: Optional[str] = "COSINE"
Expand Down Expand Up @@ -126,13 +126,16 @@ def _get_db_path(self, config: RepoConfig) -> str:

def _connect(self, config: RepoConfig) -> MilvusClient:
if not self.client:
if config.provider == "local":
if config.provider == "local" and config.online_store.path:
db_path = self._get_db_path(config)
print(f"Connecting to Milvus in local mode using {db_path}")
self.client = MilvusClient(db_path)
else:
print(
f"Connecting to Milvus remotely at {config.online_store.host}:{config.online_store.port}"
)
self.client = MilvusClient(
url=f"{config.online_store.host}:{config.online_store.port}",
uri=f"{config.online_store.host}:{config.online_store.port}",
token=f"{config.online_store.username}:{config.online_store.password}"
if config.online_store.username and config.online_store.password
else "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
)

DYNAMO_CONFIG = {"type": "dynamodb", "region": "us-west-2"}
MILVUS_CONFIG = {"type": "milvus", "embedding_dim": "2"}
MILVUS_CONFIG = {"type": "milvus", "embedding_dim": 2, "path": "online_store.db"}
REDIS_CONFIG = {"type": "redis", "connection_string": "localhost:6379,db=0"}
REDIS_CLUSTER_CONFIG = {
"type": "redis",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
from typing import Any, Dict

import docker
from testcontainers.core.container import DockerContainer
from testcontainers.core.waiting_utils import wait_for_logs

from tests.integration.feature_repos.universal.online_store_creator import (
OnlineStoreCreator,
)
Expand All @@ -12,33 +8,14 @@
class MilvusOnlineStoreCreator(OnlineStoreCreator):
def __init__(self, project_name: str, **kwargs):
super().__init__(project_name)
self.fixed_port = 19530
self.container = DockerContainer("milvusdb/milvus:v2.4.9").with_exposed_ports(
self.fixed_port
)
self.client = docker.from_env()

def create_online_store(self) -> Dict[str, Any]:
self.container.start()
# Wait for Milvus server to be ready
# log_string_to_wait_for = "Ready to accept connections"
log_string_to_wait_for = ""
wait_for_logs(
container=self.container, predicate=log_string_to_wait_for, timeout=30
)
host = "localhost"
port = self.container.get_exposed_port(self.fixed_port)
return {
"type": "milvus",
"host": host,
"port": int(port),
"path": "online_store.db",
"index_type": "IVF_FLAT",
"metric_type": "L2",
"embedding_dim": 2,
"vector_enabled": True,
"nlist": 1,
}

def teardown(self):
self.container.stop()
Loading