Skip to content

Commit

Permalink
fix: Passing messages to code in ParamError (#2304)
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 bb69c1d commit c6e0326
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions pymilvus/client/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,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 @@ -466,7 +466,8 @@ def _parse_row_request(
expected_num_input_fields = len(input_fields_info) + (1 if enable_dynamic else 0)

if len(fields_data) != expected_num_input_fields:
raise ParamError(ExceptionsMessage.FieldsNumInconsistent)
msg = f"{ExceptionsMessage.FieldsNumInconsistent}, expected {expected_num_input_fields} fields, got {len(fields_data)}"
raise ParamError(message=msg)

return request

Expand Down Expand Up @@ -553,7 +554,8 @@ def _parse_upsert_row_request(
expected_num_input_fields = len(input_fields_info) + (1 if enable_dynamic else 0)

if len(fields_data) != expected_num_input_fields:
raise ParamError(ExceptionsMessage.FieldsNumInconsistent)
msg = f"{ExceptionsMessage.FieldsNumInconsistent}, expected {expected_num_input_fields} fields, got {len(fields_data)}"
raise ParamError(message=msg)

return request

Expand Down Expand Up @@ -628,7 +630,7 @@ def _pre_insert_batch_check(

if len(entities) != expected_num_input_fields:
msg = f"expected number of fields: {expected_num_input_fields}, actual number of fields in entities: {len(entities)}"
raise ParamError(msg)
raise ParamError(message=msg)

return location

Expand Down Expand Up @@ -659,7 +661,7 @@ def _pre_upsert_batch_check(

if len(entities) != expected_num_input_fields:
msg = f"expected number of fields: {expected_num_input_fields}, actual number of fields in entities: {len(entities)}"
raise ParamError(msg)
raise ParamError(message=msg)
return location

@staticmethod
Expand Down Expand Up @@ -1276,15 +1278,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 c6e0326

Please sign in to comment.