From fde6ebe5ed12beea8267a57e7800bed67ccd95f1 Mon Sep 17 00:00:00 2001 From: wayblink Date: Thu, 8 Aug 2024 14:51:15 +0800 Subject: [PATCH] Rename is_major to is_clustering Signed-off-by: wayblink --- pymilvus/client/grpc_handler.py | 4 ++-- pymilvus/client/prepare.py | 4 ++-- pymilvus/client/stub.py | 18 ++++++++++-------- pymilvus/orm/collection.py | 32 ++++++++++++++++++-------------- 4 files changed, 32 insertions(+), 26 deletions(-) diff --git a/pymilvus/client/grpc_handler.py b/pymilvus/client/grpc_handler.py index fd7998305..f3645ba19 100644 --- a/pymilvus/client/grpc_handler.py +++ b/pymilvus/client/grpc_handler.py @@ -1549,7 +1549,7 @@ def compact( self, collection_name: str, timeout: Optional[float] = None, - is_major: Optional[bool] = False, + is_clustering: Optional[bool] = False, **kwargs, ) -> int: request = Prepare.describe_collection_request(collection_name) @@ -1557,7 +1557,7 @@ def compact( response = rf.result() check_status(response.status) - req = Prepare.manual_compaction(response.collectionID, is_major) + req = Prepare.manual_compaction(response.collectionID, is_clustering) future = self._stub.ManualCompaction.future(req, timeout=timeout) response = future.result() check_status(response.status) diff --git a/pymilvus/client/prepare.py b/pymilvus/client/prepare.py index bda717579..a345390e0 100644 --- a/pymilvus/client/prepare.py +++ b/pymilvus/client/prepare.py @@ -995,13 +995,13 @@ def load_balance_request( ) @classmethod - def manual_compaction(cls, collection_id: int, is_major: bool): + def manual_compaction(cls, collection_id: int, is_clustering: bool): if collection_id is None or not isinstance(collection_id, int): raise ParamError(message=f"collection_id value {collection_id} is illegal") request = milvus_types.ManualCompactionRequest() request.collectionID = collection_id - request.majorCompaction = is_major + request.majorCompaction = is_clustering return request diff --git a/pymilvus/client/stub.py b/pymilvus/client/stub.py index 90f80699f..2460faade 100644 --- a/pymilvus/client/stub.py +++ b/pymilvus/client/stub.py @@ -1044,7 +1044,7 @@ def load_balance( **kwargs, ) - def compact(self, collection_name, timeout=None, is_major=False, **kwargs) -> int: + def compact(self, collection_name, timeout=None, is_clustering=False, **kwargs) -> int: """ Do compaction for the collection. @@ -1054,8 +1054,8 @@ def compact(self, collection_name, timeout=None, is_major=False, **kwargs) -> in :param timeout: The timeout for this method, unit: second :type timeout: int - :param is_major: trigger major compaction - :type is_major: bool + :param is_clustering: trigger clustering compaction + :type is_clustering: bool :return: the compaction ID :rtype: int @@ -1063,10 +1063,12 @@ def compact(self, collection_name, timeout=None, is_major=False, **kwargs) -> in :raises MilvusException: If collection name not exist. """ with self._connection() as handler: - return handler.compact(collection_name, timeout=timeout, is_major=is_major, **kwargs) + return handler.compact( + collection_name, timeout=timeout, is_clustering=is_clustering, **kwargs + ) def get_compaction_state( - self, compaction_id: int, timeout=None, is_major=False, **kwargs + self, compaction_id: int, timeout=None, is_clustering=False, **kwargs ) -> CompactionState: """ Get compaction states of a targeted compaction id @@ -1077,8 +1079,8 @@ def get_compaction_state( :param timeout: The timeout for this method, unit: second :type timeout: int - :param is_major: get major compaction - :type is_major: bool + :param is_clustering: get clustering compaction + :type is_clustering: bool :return: the state of the compaction :rtype: CompactionState @@ -1088,7 +1090,7 @@ def get_compaction_state( with self._connection() as handler: return handler.get_compaction_state( - compaction_id, timeout=timeout, is_major=is_major, **kwargs + compaction_id, timeout=timeout, is_clustering=is_clustering, **kwargs ) def wait_for_compaction_completed( diff --git a/pymilvus/orm/collection.py b/pymilvus/orm/collection.py index 760ddc4de..5b92908aa 100644 --- a/pymilvus/orm/collection.py +++ b/pymilvus/orm/collection.py @@ -1487,7 +1487,9 @@ def drop_index(self, timeout: Optional[float] = None, **kwargs): **copy_kwargs, ) - def compact(self, timeout: Optional[float] = None, is_major: Optional[bool] = False, **kwargs): + def compact( + self, timeout: Optional[float] = None, is_clustering: Optional[bool] = False, **kwargs + ): """Compact merge the small segments in a collection Args: @@ -1495,23 +1497,23 @@ def compact(self, timeout: Optional[float] = None, is_major: Optional[bool] = Fa for the RPC. When timeout is set to None, client waits until server response or error occur. - is_major (``bool``, optional): An optional setting to trigger major compaction. + is_clustering (``bool``, optional): Option to trigger clustering compaction. Raises: MilvusException: If anything goes wrong. """ conn = self._get_connection() - if is_major: - self.major_compaction_id = conn.compact( - self._name, timeout=timeout, is_major=is_major, **kwargs + if is_clustering: + self.clustering_compaction_id = conn.compact( + self._name, timeout=timeout, is_clustering=is_clustering, **kwargs ) else: self.compaction_id = conn.compact( - self._name, timeout=timeout, is_major=is_major, **kwargs + self._name, timeout=timeout, is_clustering=is_clustering, **kwargs ) def get_compaction_state( - self, timeout: Optional[float] = None, is_major: Optional[bool] = False, **kwargs + self, timeout: Optional[float] = None, is_clustering: Optional[bool] = False, **kwargs ) -> CompactionState: """Get the current compaction state @@ -1520,20 +1522,22 @@ def get_compaction_state( for the RPC. When timeout is set to None, client waits until server response or error occur. - is_major (``bool``, optional): An optional setting to get major compaction state. + is_clustering (``bool``, optional): Option to get clustering compaction state. Raises: MilvusException: If anything goes wrong. """ conn = self._get_connection() - if is_major: - return conn.get_compaction_state(self.major_compaction_id, timeout=timeout, **kwargs) + if is_clustering: + return conn.get_compaction_state( + self.clustering_compaction_id, timeout=timeout, **kwargs + ) return conn.get_compaction_state(self.compaction_id, timeout=timeout, **kwargs) def wait_for_compaction_completed( self, timeout: Optional[float] = None, - is_major: Optional[bool] = False, + is_clustering: Optional[bool] = False, **kwargs, ) -> CompactionState: """Block until the current collection's compaction completed @@ -1543,15 +1547,15 @@ def wait_for_compaction_completed( for the RPC. When timeout is set to None, client waits until server response or error occur. - is_major (``bool``, optional): An optional setting to get major compaction state. + is_clustering (``bool``, optional): Option to get clustering compaction state. Raises: MilvusException: If anything goes wrong. """ conn = self._get_connection() - if is_major: + if is_clustering: return conn.wait_for_compaction_completed( - self.major_compaction_id, timeout=timeout, **kwargs + self.clustering_compaction_id, timeout=timeout, **kwargs ) return conn.wait_for_compaction_completed(self.compaction_id, timeout=timeout, **kwargs)