From b66955139b1fd1a87c81fa1c04e3c9e6f804b0d4 Mon Sep 17 00:00:00 2001 From: "zhenshan.cao" Date: Mon, 25 Nov 2024 15:04:27 +0800 Subject: [PATCH] Add default values to Pop to prevent exceptions (#2373) issue https://github.com/milvus-io/pymilvus/issues/2327 related to https://github.com/milvus-io/pymilvus/pull/2350 Signed-off-by: zhenshan.cao Signed-off-by: Ruichen Bao --- pymilvus/__init__.py | 96 ++++++++++++++++----------------- pymilvus/bulk_writer/buffer.py | 8 +-- pymilvus/client/check.py | 2 +- pymilvus/client/grpc_handler.py | 2 +- 4 files changed, 54 insertions(+), 54 deletions(-) diff --git a/pymilvus/__init__.py b/pymilvus/__init__.py index 21b5f99ed..7c01c7d78 100644 --- a/pymilvus/__init__.py +++ b/pymilvus/__init__.py @@ -72,65 +72,65 @@ from .settings import Config as DefaultConfig __all__ = [ + "AnnSearchRequest", + "BulkInsertState", "Collection", + "CollectionSchema", + "Connections", + "DataType", + "DefaultConfig", + "ExceptionsMessage", + "FieldSchema", + "Function", + "FunctionType", + "Group", + "Hit", + "Hits", "Index", + "IndexType", + "Milvus", + "MilvusClient", + "MilvusException", + "MilvusUnavailableException", + "MutationFuture", "Partition", + "Prepare", + "RRFRanker", + "Replica", + "ResourceGroupInfo", + "Role", + "SearchFuture", + "SearchResult", + "Shard", + "Status", + "WeightedRanker", + "__version__", "connections", - "loading_progress", - "index_building_progress", - "wait_for_index_building_complete", + "create_resource_group", + "create_user", + "db", + "delete_user", + "describe_resource_group", "drop_collection", + "drop_resource_group", "has_collection", - "list_collections", - "wait_for_loading_complete", "has_partition", + "hybridts_to_datetime", + "hybridts_to_unixtime", + "index_building_progress", + "list_collections", + "list_resource_groups", + "list_usernames", + "loading_progress", + "mkts_from_datetime", "mkts_from_hybridts", "mkts_from_unixtime", - "mkts_from_datetime", - "hybridts_to_unixtime", - "hybridts_to_datetime", "reset_password", - "create_user", + "transfer_node", + "transfer_replica", "update_password", "update_resource_groups", - "delete_user", - "list_usernames", - "SearchResult", - "Hits", - "Hit", - "Replica", - "Group", - "Shard", - "FieldSchema", - "Function", - "CollectionSchema", - "SearchFuture", - "MutationFuture", "utility", - "db", - "DefaultConfig", - "Role", - "ExceptionsMessage", - "MilvusUnavailableException", - "BulkInsertState", - "create_resource_group", - "drop_resource_group", - "describe_resource_group", - "list_resource_groups", - "transfer_node", - "transfer_replica", - "Milvus", - "Prepare", - "Status", - "DataType", - "FunctionType", - "MilvusException", - "__version__", - "MilvusClient", - "ResourceGroupInfo", - "Connections", - "IndexType", - "AnnSearchRequest", - "RRFRanker", - "WeightedRanker", + "wait_for_index_building_complete", + "wait_for_loading_complete", ] diff --git a/pymilvus/bulk_writer/buffer.py b/pymilvus/bulk_writer/buffer.py index 2935e575b..63b94aef4 100644 --- a/pymilvus/bulk_writer/buffer.py +++ b/pymilvus/bulk_writer/buffer.py @@ -93,15 +93,15 @@ def append_row(self, row: dict): if DYNAMIC_FIELD_NAME in row and not isinstance(row[DYNAMIC_FIELD_NAME], dict): self._throw(f"Dynamic field '{DYNAMIC_FIELD_NAME}' value should be JSON format") - for k in row: + for k, v in row.items(): if k == DYNAMIC_FIELD_NAME: - dynamic_values.update(row[k]) + dynamic_values.update(v) continue if k not in self._buffer: - dynamic_values[k] = self._raw_obj(row[k]) + dynamic_values[k] = self._raw_obj(v) else: - self._buffer[k].append(row[k]) + self._buffer[k].append(v) if DYNAMIC_FIELD_NAME in self._buffer: self._buffer[DYNAMIC_FIELD_NAME].append(dynamic_values) diff --git a/pymilvus/client/check.py b/pymilvus/client/check.py index 9cae7b6f7..a0c3832c3 100644 --- a/pymilvus/client/check.py +++ b/pymilvus/client/check.py @@ -244,7 +244,7 @@ def is_legal_round_decimal(round_decimal: Any) -> bool: def is_legal_guarantee_timestamp(ts: Any) -> bool: - return ts is None or isinstance(ts, int) and ts >= 0 + return (ts is None) or (isinstance(ts, int) and ts >= 0) def is_legal_user(user: Any) -> bool: diff --git a/pymilvus/client/grpc_handler.py b/pymilvus/client/grpc_handler.py index 8274c0b32..9a9791a84 100644 --- a/pymilvus/client/grpc_handler.py +++ b/pymilvus/client/grpc_handler.py @@ -604,7 +604,7 @@ def delete( ) future = self._stub.Delete.future(req, timeout=timeout) if kwargs.get("_async", False): - cb = kwargs.pop("_callback") + cb = kwargs.pop("_callback", None) f = MutationFuture(future, cb, timeout=timeout, **kwargs) f.add_callback(ts_utils.update_ts_on_mutation(collection_name)) return f