Skip to content

Commit

Permalink
fix: Passing messages to code in ParamError (#2304) (#2305)
Browse files Browse the repository at this point in the history
See also: milvus-io/milvus#36983

Signed-off-by: yangxuan <[email protected]>
  • Loading branch information
XuanYang-cn authored Oct 21, 2024
1 parent c133c2d commit df326c6
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions pymilvus/client/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -1150,15 +1150,15 @@ 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)

@classmethod
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,
Expand Down

0 comments on commit df326c6

Please sign in to comment.