Skip to content

Commit 6216e07

Browse files
remove redundant empty_field config check for qdrant and tidb
Signed-off-by: min.tian <min.tian.cn@gmail.com>
1 parent a39fe83 commit 6216e07

2 files changed

Lines changed: 7 additions & 18 deletions

File tree

vectordb_bench/backend/clients/qdrant_cloud/config.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from pydantic import BaseModel, SecretStr, validator
1+
from pydantic import BaseModel, SecretStr
22

33
from ..api import DBCaseConfig, DBConfig, MetricType
44

@@ -20,14 +20,6 @@ def to_dict(self) -> dict:
2020
"url": self.url.get_secret_value(),
2121
}
2222

23-
@validator("*")
24-
def not_empty_field(cls, v: any, field: any):
25-
if field.name in ["api_key", "db_label"]:
26-
return v
27-
if isinstance(v, str | SecretStr) and len(v) == 0:
28-
raise ValueError("Empty string!")
29-
return v
30-
3123

3224
class QdrantIndexConfig(BaseModel, DBCaseConfig):
3325
metric_type: MetricType | None = None

vectordb_bench/backend/clients/tidb/config.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
from pydantic import SecretStr, BaseModel, validator
2-
from ..api import DBConfig, DBCaseConfig, MetricType
1+
from pydantic import BaseModel, SecretStr
2+
3+
from ..api import DBCaseConfig, DBConfig, MetricType
34

45

56
class TiDBConfig(DBConfig):
@@ -10,10 +11,6 @@ class TiDBConfig(DBConfig):
1011
db_name: str = "test"
1112
ssl: bool = False
1213

13-
@validator("*")
14-
def not_empty_field(cls, v: any, field: any):
15-
return v
16-
1714
def to_dict(self) -> dict:
1815
pwd_str = self.password.get_secret_value()
1916
return {
@@ -33,10 +30,10 @@ class TiDBIndexConfig(BaseModel, DBCaseConfig):
3330
def get_metric_fn(self) -> str:
3431
if self.metric_type == MetricType.L2:
3532
return "vec_l2_distance"
36-
elif self.metric_type == MetricType.COSINE:
33+
if self.metric_type == MetricType.COSINE:
3734
return "vec_cosine_distance"
38-
else:
39-
raise ValueError(f"Unsupported metric type: {self.metric_type}")
35+
msg = f"Unsupported metric type: {self.metric_type}"
36+
raise ValueError(msg)
4037

4138
def index_param(self) -> dict:
4239
return {

0 commit comments

Comments
 (0)