Skip to content

Commit

Permalink
Fix double param error (#1247)
Browse files Browse the repository at this point in the history
See also: milvus-io/milvus#21003

Signed-off-by: yangxuan <[email protected]>

Signed-off-by: yangxuan <[email protected]>
  • Loading branch information
XuanYang-cn authored Dec 6, 2022
1 parent d368f14 commit b151592
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
12 changes: 6 additions & 6 deletions pymilvus/client/grpc_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ def _execute_search_requests(self, requests, timeout=None, **kwargs):
@retry_on_rpc_failure(retry_on_deadline=False)
def search(self, collection_name, data, anns_field, param, limit,
expression=None, partition_names=None, output_fields=None,
round_decimal=-1, timeout=None, collection_schema=None, **kwargs):
round_decimal=-1, timeout=None, schema=None, **kwargs):
check_pass_param(
limit=limit,
round_decimal=round_decimal,
Expand All @@ -452,20 +452,20 @@ def search(self, collection_name, data, anns_field, param, limit,
guarantee_timestamp=kwargs.get("guarantee_timestamp", 0)
)

if not collection_schema:
collection_schema = self.describe_collection(collection_name, timeout=timeout, **kwargs)
if schema is None:
schema = self.describe_collection(collection_name, timeout=timeout, **kwargs)

consistency_level = collection_schema["consistency_level"]
consistency_level = schema["consistency_level"]
# overwrite the consistency level defined when user created the collection
consistency_level = get_consistency_level(kwargs.get("consistency_level", consistency_level))

ts_utils.construct_guarantee_ts(consistency_level, collection_name, kwargs)

requests = Prepare.search_requests_with_expr(collection_name, data, anns_field, param, limit, collection_schema,
requests = Prepare.search_requests_with_expr(collection_name, data, anns_field, param, limit, schema,
expression, partition_names, output_fields, round_decimal,
**kwargs)

auto_id = collection_schema["auto_id"]
auto_id = schema["auto_id"]
return self._execute_search_requests(requests, timeout, round_decimal=round_decimal, auto_id=auto_id, **kwargs)

@retry_on_rpc_failure()
Expand Down
4 changes: 2 additions & 2 deletions pymilvus/client/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,8 @@ def extract_vectors_param(param, placeholders, names, round_decimal):
return request

@classmethod
def search_requests_with_expr(cls, collection_name, data, anns_field, param, limit, schema, expr=None, partition_names=None,
output_fields=None, round_decimal=-1, **kwargs):
def search_requests_with_expr(cls, collection_name, data, anns_field, param, limit, schema, expr=None,
partition_names=None, output_fields=None, round_decimal=-1, **kwargs):
# TODO Move this impl into server side
fields_schema = schema.get("fields", None) # list
fields_name_locs = {fields_schema[loc]["name"]: loc for loc in range(len(fields_schema))}
Expand Down
1 change: 0 additions & 1 deletion tests/test_prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def test_create_collection_with_properties(self, valid_properties):
FieldSchema("pk_field", DataType.INT64, is_primary=True, auto_id=True)
])
req = Prepare.create_collection_request("c_name", schema, **valid_properties)

assert len(valid_properties.get("properties")) == len(req.properties)

@pytest.mark.parametrize("invalid_fields", [
Expand Down

0 comments on commit b151592

Please sign in to comment.