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
20 changes: 20 additions & 0 deletions vectordb_bench/backend/clients/milvus/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ class MilvusTypedDict(TypedDict):
str | None,
click.option("--password", type=str, help="Db password", required=False),
]
num_shards: Annotated[
int,
click.option(
"--num-shards",
type=int,
help="Number of shards",
required=False,
default=1,
show_default=True,
),
]


class MilvusAutoIndexTypedDict(CommonTypedDict, MilvusTypedDict): ...
Expand All @@ -46,6 +57,7 @@ def MilvusAutoIndex(**parameters: Unpack[MilvusAutoIndexTypedDict]):
uri=SecretStr(parameters["uri"]),
user=parameters["user_name"],
password=SecretStr(parameters["password"]),
num_shards=int(parameters["num_shards"]),
),
db_case_config=AutoIndexConfig(),
**parameters,
Expand All @@ -64,6 +76,7 @@ def MilvusFlat(**parameters: Unpack[MilvusAutoIndexTypedDict]):
uri=SecretStr(parameters["uri"]),
user=parameters["user_name"],
password=SecretStr(parameters["password"]),
num_shards=int(parameters["num_shards"]),
),
db_case_config=FLATConfig(),
**parameters,
Expand Down Expand Up @@ -110,6 +123,7 @@ def MilvusIVFFlat(**parameters: Unpack[MilvusIVFFlatTypedDict]):
uri=SecretStr(parameters["uri"]),
user=parameters["user_name"],
password=SecretStr(parameters["password"]),
num_shards=int(parameters["num_shards"]),
),
db_case_config=IVFFlatConfig(
nlist=parameters["nlist"],
Expand All @@ -131,6 +145,7 @@ def MilvusIVFSQ8(**parameters: Unpack[MilvusIVFFlatTypedDict]):
uri=SecretStr(parameters["uri"]),
user=parameters["user_name"],
password=SecretStr(parameters["password"]),
num_shards=int(parameters["num_shards"]),
),
db_case_config=IVFSQ8Config(
nlist=parameters["nlist"],
Expand All @@ -156,6 +171,7 @@ def MilvusDISKANN(**parameters: Unpack[MilvusDISKANNTypedDict]):
uri=SecretStr(parameters["uri"]),
user=parameters["user_name"],
password=SecretStr(parameters["password"]),
num_shards=int(parameters["num_shards"]),
),
db_case_config=DISKANNConfig(
search_list=parameters["search_list"],
Expand Down Expand Up @@ -184,6 +200,7 @@ def MilvusGPUIVFFlat(**parameters: Unpack[MilvusGPUIVFTypedDict]):
uri=SecretStr(parameters["uri"]),
user=parameters["user_name"],
password=SecretStr(parameters["password"]),
num_shards=int(parameters["num_shards"]),
),
db_case_config=GPUIVFFlatConfig(
nlist=parameters["nlist"],
Expand Down Expand Up @@ -218,6 +235,7 @@ def MilvusGPUBruteForce(**parameters: Unpack[MilvusGPUBruteForceTypedDict]):
uri=SecretStr(parameters["uri"]),
user=parameters["user_name"],
password=SecretStr(parameters["password"]),
num_shards=int(parameters["num_shards"]),
),
db_case_config=GPUBruteForceConfig(
metric_type=parameters["metric_type"],
Expand Down Expand Up @@ -249,6 +267,7 @@ def MilvusGPUIVFPQ(**parameters: Unpack[MilvusGPUIVFPQTypedDict]):
uri=SecretStr(parameters["uri"]),
user=parameters["user_name"],
password=SecretStr(parameters["password"]),
num_shards=int(parameters["num_shards"]),
),
db_case_config=GPUIVFPQConfig(
nlist=parameters["nlist"],
Expand Down Expand Up @@ -288,6 +307,7 @@ def MilvusGPUCAGRA(**parameters: Unpack[MilvusGPUCAGRATypedDict]):
uri=SecretStr(parameters["uri"]),
user=parameters["user_name"],
password=SecretStr(parameters["password"]),
num_shards=int(parameters["num_shards"]),
),
db_case_config=GPUCAGRAConfig(
intermediate_graph_degree=parameters["intermediate_graph_degree"],
Expand Down
1 change: 1 addition & 0 deletions vectordb_bench/backend/clients/milvus/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class MilvusConfig(DBConfig):
uri: SecretStr = "http://localhost:19530"
user: str | None = None
password: SecretStr | None = None
num_shards: int = 1

def to_dict(self) -> dict:
return {
Expand Down
8 changes: 7 additions & 1 deletion vectordb_bench/backend/clients/milvus/milvus.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ def __init__(

from pymilvus import connections

connections.connect(**self.db_config, timeout=30)
connections.connect(
uri=self.db_config.get("uri"),
user=self.db_config.get("user"),
password=self.db_config.get("password"),
timeout=30,
)
if drop_old and utility.has_collection(self.collection_name):
log.info(f"{self.name} client drop_old collection: {self.collection_name}")
utility.drop_collection(self.collection_name)
Expand All @@ -59,6 +64,7 @@ def __init__(
name=self.collection_name,
schema=CollectionSchema(fields),
consistency_level="Session",
num_shards=self.db_config.get("num_shards"),
)

log.info(f"{self.name} create index: index_params: {self.case_config.index_param()}")
Expand Down