From 2b60cd9d8078beab274ab4239f3b77c96e9bf080 Mon Sep 17 00:00:00 2001 From: XuanYang-cn Date: Mon, 21 Oct 2024 11:51:19 +0800 Subject: [PATCH] fix: Passing messages to code in ParamError (#2304) See also: milvus-io/milvus#36983 Signed-off-by: yangxuan --- pymilvus/client/prepare.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pymilvus/client/prepare.py b/pymilvus/client/prepare.py index 9c217343e..92f2078c6 100644 --- a/pymilvus/client/prepare.py +++ b/pymilvus/client/prepare.py @@ -315,7 +315,7 @@ def show_partitions_request( if partition_names: if not isinstance(partition_names, (list,)): msg = f"partition_names must be a list of strings, but got: {partition_names}" - raise ParamError(msg) + raise ParamError(message=msg) for partition_name in partition_names: check_pass_param(partition_name=partition_name) req.partition_names.extend(partition_names) @@ -419,9 +419,9 @@ def _parse_row_request( if (enable_dynamic and len(fields_data) != len(fields_info)) or ( not enable_dynamic and len(fields_data) + 1 != len(fields_info) ): - raise ParamError(ExceptionsMessage.FieldsNumInconsistent) + raise ParamError(message=ExceptionsMessage.FieldsNumInconsistent) elif enable_dynamic and len(fields_data) != len(fields_info) + 1: - raise ParamError(ExceptionsMessage.FieldsNumInconsistent) + raise ParamError(message=ExceptionsMessage.FieldsNumInconsistent) return request @staticmethod @@ -488,7 +488,7 @@ def _parse_upsert_row_request( if (enable_dynamic and len(fields_data) != len(fields_info) + 1) or ( not enable_dynamic and len(fields_data) != len(fields_info) ): - raise ParamError(ExceptionsMessage.FieldsNumInconsistent) + raise ParamError(message=ExceptionsMessage.FieldsNumInconsistent) return request @classmethod @@ -559,12 +559,12 @@ def _pre_insert_batch_check( raise ParamError(message="primary key not found") if auto_id_loc is None and len(entities) != len(fields_info): - msg = f"number of fields: {len(fields_info)}, number of entities: {len(entities)}" - raise ParamError(msg) + msg = f"expected number of fields: {len(fields_info)}, actual number of fields in entities: {len(entities)}" + raise ParamError(message=msg) if auto_id_loc is not None and len(entities) + 1 != len(fields_info): - msg = f"number of fields: {len(fields_info)}, number of entities: {len(entities)}" - raise ParamError(msg) + msg = f"expected number of fields: {len(fields_info)}, actual number of fields in entities: {len(entities)}" + raise ParamError(message=msg) return location @staticmethod @@ -591,8 +591,8 @@ def _pre_upsert_batch_check( raise ParamError(message="primary key not found") if len(entities) != len(fields_info): - msg = f"number of fields: {len(fields_info)}, number of entities: {len(entities)}" - raise ParamError(msg) + msg = f"expected number of fields: {len(fields_info)}, got number of fields in entities: {len(entities)}" + raise ParamError(message=msg) return location @staticmethod @@ -1150,7 +1150,7 @@ def do_bulk_insert(cls, collection_name: str, partition_name: str, files: list, def get_bulk_insert_state(cls, task_id: int): if task_id is None or not isinstance(task_id, int): msg = f"task_id value {task_id} is not an integer" - raise ParamError(msg) + raise ParamError(message=msg) return milvus_types.GetImportStateRequest(task=task_id) @@ -1158,7 +1158,7 @@ def get_bulk_insert_state(cls, task_id: int): def list_bulk_insert_tasks(cls, limit: int, collection_name: str): if limit is None or not isinstance(limit, int): msg = f"limit value {limit} is not an integer" - raise ParamError(msg) + raise ParamError(message=msg) return milvus_types.ListImportTasksRequest( collection_name=collection_name,