Skip to content

Commit 8ddcce8

Browse files
authored
fix: [cp25]Add and check timeout param in database api (#2665)
See also: #2594 Signed-off-by: yangxuan <[email protected]>
1 parent 6df2d70 commit 8ddcce8

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

pymilvus/client/grpc_handler.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1240,8 +1240,7 @@ def wait_for_creating_index(
12401240
end = time.time()
12411241
if isinstance(timeout, int) and end - start > timeout:
12421242
msg = (
1243-
f"collection {collection_name} create index {index_name} "
1244-
f"timeout in {timeout}s"
1243+
f"collection {collection_name} create index {index_name} timeout in {timeout}s"
12451244
)
12461245
raise MilvusException(message=msg)
12471246

@@ -1427,7 +1426,8 @@ def create_database(
14271426
timeout: Optional[float] = None,
14281427
**kwargs,
14291428
):
1430-
request = Prepare.create_database_req(db_name, properties=properties, **kwargs)
1429+
check_pass_param(db_name=db_name, timeout=timeout)
1430+
request = Prepare.create_database_req(db_name, properties=properties)
14311431
status = self._stub.CreateDatabase(request, timeout=timeout)
14321432
check_status(status)
14331433

@@ -1439,6 +1439,7 @@ def drop_database(self, db_name: str, timeout: Optional[float] = None):
14391439

14401440
@retry_on_rpc_failure()
14411441
def list_database(self, timeout: Optional[float] = None):
1442+
check_pass_param(timeout=timeout)
14421443
request = Prepare.list_database_req()
14431444
response = self._stub.ListDatabases(request, timeout=timeout)
14441445
check_status(response.status)

pymilvus/client/prepare.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -1662,11 +1662,9 @@ def register_request(cls, user: str, host: str, **kwargs):
16621662
)
16631663

16641664
@classmethod
1665-
def create_database_req(cls, db_name: str, **kwargs):
1666-
check_pass_param(db_name=db_name)
1667-
1665+
def create_database_req(cls, db_name: str, properties: Optional[dict] = None):
16681666
req = milvus_types.CreateDatabaseRequest(db_name=db_name)
1669-
properties = kwargs.get("properties")
1667+
16701668
if is_legal_collection_properties(properties):
16711669
properties = [
16721670
common_types.KeyValuePair(key=str(k), value=str(v)) for k, v in properties.items()

pymilvus/milvus_client/milvus_client.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ def _pack_pks_expr(self, schema_dict: Dict, pks: List) -> str:
945945
# Varchar pks need double quotes around the values
946946
if data_type == DataType.VARCHAR:
947947
ids = ["'" + str(entry) + "'" for entry in pks]
948-
expr = f"""{pk_field_name} in [{','.join(ids)}]"""
948+
expr = f"""{pk_field_name} in [{",".join(ids)}]"""
949949
else:
950950
ids = [str(entry) for entry in pks]
951951
expr = f"{pk_field_name} in [{','.join(ids)}]"
@@ -1371,17 +1371,23 @@ def use_database(self, db_name: str, **kwargs):
13711371
conn = self._get_connection()
13721372
conn.reset_db_name(db_name)
13731373

1374-
def create_database(self, db_name: str, properties: Optional[dict] = None, **kwargs):
1374+
def create_database(
1375+
self,
1376+
db_name: str,
1377+
properties: Optional[dict] = None,
1378+
timeout: Optional[float] = None,
1379+
**kwargs,
1380+
):
13751381
conn = self._get_connection()
1376-
conn.create_database(db_name, properties, **kwargs)
1382+
conn.create_database(db_name=db_name, properties=properties, timeout=timeout, **kwargs)
13771383

13781384
def drop_database(self, db_name: str, **kwargs):
13791385
conn = self._get_connection()
13801386
conn.drop_database(db_name, **kwargs)
13811387

1382-
def list_databases(self, **kwargs) -> List[str]:
1388+
def list_databases(self, timeout: Optional[float] = None, **kwargs) -> List[str]:
13831389
conn = self._get_connection()
1384-
return conn.list_database(**kwargs)
1390+
return conn.list_database(timeout=timeout, **kwargs)
13851391

13861392
def describe_database(self, db_name: str, **kwargs) -> dict:
13871393
conn = self._get_connection()

0 commit comments

Comments
 (0)