Skip to content

Commit

Permalink
enhance: alterdatabase support delete property (#2435)
Browse files Browse the repository at this point in the history
alterdatabase support delete property
issue: milvus-io/milvus#38379

---------

Signed-off-by: Xianhui.Lin <[email protected]>
  • Loading branch information
JsDove authored Dec 12, 2024
1 parent 6ce08b2 commit 3a1f3d1
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 45 deletions.
16 changes: 12 additions & 4 deletions pymilvus/client/grpc_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,13 +334,13 @@ def alter_collection_field_properties(
self,
collection_name: str,
field_name: str,
field_param: List,
field_params: List,
timeout: Optional[float] = None,
**kwargs,
):
check_pass_param(collection_name=collection_name, properties=field_param, timeout=timeout)
check_pass_param(collection_name=collection_name, properties=field_params, timeout=timeout)
request = Prepare.alter_collection_field_request(
self, collection_name=collection_name, field_name=field_name, field_param=field_param
collection_name=collection_name, field_name=field_name, field_param=field_params
)
rf = self._stub.AlterCollectionField.future(request, timeout=timeout)
status = rf.result()
Expand Down Expand Up @@ -1381,7 +1381,15 @@ def list_database(self, timeout: Optional[float] = None):
def alter_database(
self, db_name: str, properties: dict, timeout: Optional[float] = None, **kwargs
):
request = Prepare.alter_database_req(db_name, properties)
request = Prepare.alter_database_properties_req(db_name, properties)
status = self._stub.AlterDatabase(request, timeout=timeout)
check_status(status)

@retry_on_rpc_failure()
def drop_database_properties(
self, db_name: str, property_keys: List[str], timeout: Optional[float] = None, **kwargs
):
request = Prepare.drop_database_properties_req(db_name, property_keys)
status = self._stub.AlterDatabase(request, timeout=timeout)
check_status(status)

Expand Down
7 changes: 6 additions & 1 deletion pymilvus/client/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -1643,11 +1643,16 @@ def list_database_req(cls):
return milvus_types.ListDatabasesRequest()

@classmethod
def alter_database_req(cls, db_name: str, properties: Dict):
def alter_database_properties_req(cls, db_name: str, properties: Dict):
check_pass_param(db_name=db_name)
kvs = [common_types.KeyValuePair(key=k, value=str(v)) for k, v in properties.items()]
return milvus_types.AlterDatabaseRequest(db_name=db_name, properties=kvs)

@classmethod
def drop_database_properties_req(cls, db_name: str, property_keys: List[str]):
check_pass_param(db_name=db_name)
return milvus_types.AlterDatabaseRequest(db_name=db_name, delete_keys=property_keys)

@classmethod
def describe_database_req(cls, db_name: str):
check_pass_param(db_name=db_name)
Expand Down
2 changes: 1 addition & 1 deletion pymilvus/grpc_gen/milvus-proto
64 changes: 32 additions & 32 deletions pymilvus/grpc_gen/milvus_pb2.py

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions pymilvus/grpc_gen/milvus_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2119,16 +2119,18 @@ class ListDatabasesResponse(_message.Message):
def __init__(self, status: _Optional[_Union[_common_pb2.Status, _Mapping]] = ..., db_names: _Optional[_Iterable[str]] = ..., created_timestamp: _Optional[_Iterable[int]] = ..., db_ids: _Optional[_Iterable[int]] = ...) -> None: ...

class AlterDatabaseRequest(_message.Message):
__slots__ = ("base", "db_name", "db_id", "properties")
__slots__ = ("base", "db_name", "db_id", "properties", "delete_keys")
BASE_FIELD_NUMBER: _ClassVar[int]
DB_NAME_FIELD_NUMBER: _ClassVar[int]
DB_ID_FIELD_NUMBER: _ClassVar[int]
PROPERTIES_FIELD_NUMBER: _ClassVar[int]
DELETE_KEYS_FIELD_NUMBER: _ClassVar[int]
base: _common_pb2.MsgBase
db_name: str
db_id: str
properties: _containers.RepeatedCompositeFieldContainer[_common_pb2.KeyValuePair]
def __init__(self, base: _Optional[_Union[_common_pb2.MsgBase, _Mapping]] = ..., db_name: _Optional[str] = ..., db_id: _Optional[str] = ..., properties: _Optional[_Iterable[_Union[_common_pb2.KeyValuePair, _Mapping]]] = ...) -> None: ...
delete_keys: _containers.RepeatedScalarFieldContainer[str]
def __init__(self, base: _Optional[_Union[_common_pb2.MsgBase, _Mapping]] = ..., db_name: _Optional[str] = ..., db_id: _Optional[str] = ..., properties: _Optional[_Iterable[_Union[_common_pb2.KeyValuePair, _Mapping]]] = ..., delete_keys: _Optional[_Iterable[str]] = ...) -> None: ...

class DescribeDatabaseRequest(_message.Message):
__slots__ = ("base", "db_name")
Expand Down
14 changes: 9 additions & 5 deletions pymilvus/milvus_client/milvus_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -886,15 +886,15 @@ def alter_collection_field(
self,
collection_name: str,
field_name: str,
field_param: dict,
field_params: dict,
timeout: Optional[float] = None,
**kwargs,
):
conn = self._get_connection()
conn.alter_collection_field_properties(
collection_name,
field_name=field_name,
field_param=field_param,
field_params=field_params,
timeout=timeout,
**kwargs,
)
Expand Down Expand Up @@ -1179,14 +1179,18 @@ def list_databases(self, **kwargs) -> List[str]:
conn = self._get_connection()
return conn.list_database(**kwargs)

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

def alter_database(self, db_name: str, properties: dict, **kwargs):
def alter_database_properties(self, db_name: str, properties: dict, **kwargs):
conn = self._get_connection()
conn.alter_database(db_name, properties, **kwargs)

def drop_database_properties(self, db_name: str, property_keys: List[str], **kwargs):
conn = self._get_connection()
conn.drop_database_properties(db_name, property_keys, **kwargs)

def flush(
self,
collection_name: str,
Expand Down

0 comments on commit 3a1f3d1

Please sign in to comment.