Skip to content

Commit

Permalink
throw exception only when future.result() is called (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
longjiquan committed Mar 18, 2021
1 parent 7c8a844 commit 73ba196
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion milvus/client/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""client module"""

__version__ = "0.0.48"
__version__ = "0.0.50"
20 changes: 12 additions & 8 deletions milvus/client/grpc_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,11 +515,13 @@ def bulk_insert(self, collection_name, entities, ids=None, partition_tag=None, p
return list(ids)

raise BaseException(response.status.error_code, response.status.reason)
except DescribeCollectionException as desc_error:
if kwargs.get("_async", False):
return InsertFuture(None, None, desc_error)
raise desc_error
# except DescribeCollectionException as desc_error:
# if kwargs.get("_async", False):
# return InsertFuture(None, None, desc_error)
# raise desc_error
except Exception as err:
if kwargs.get("_async", False):
return InsertFuture(None, None, err)
raise err

@error_handler([])
Expand Down Expand Up @@ -625,11 +627,13 @@ def search(self, collection_name, query_entities, partition_tags=None, fields=No
# resutls = self._search_hook.handle_response(response)

return QueryResult(response, auto_id)
except (CollectionNotExistException, DescribeCollectionException) as err:
if kwargs.get("_async", False):
return SearchFuture(None, None, True, err)
raise err
# except (CollectionNotExistException, DescribeCollectionException) as err:
# if kwargs.get("_async", False):
# return SearchFuture(None, None, True, err)
# raise err
except Exception as pre_err:
if kwargs.get("_async", False):
return SearchFuture(None, None, True, pre_err)
raise pre_err

@error_handler(None)
Expand Down
4 changes: 2 additions & 2 deletions milvus/client/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def bulk_insert_param(cls, collection_name, entities, partition_tag, ids=None, p

# generate hash keys, TODO: better hash function
if ids is not None:
hash_keys = [mmh3.hash(str(e)) for e in ids]
hash_keys = [abs(mmh3.hash(str(e))) for e in ids]
insert_request.hash_keys.extend(hash_keys)

return insert_request
Expand Down Expand Up @@ -434,7 +434,7 @@ def get_fields_by_schema():

# generate hash keys, TODO: better hash function
if ids is not None:
hash_keys = [mmh3.hash(str(e)) for e in ids]
hash_keys = [abs(mmh3.hash(str(e))) for e in ids]
row_batch.hash_keys.extend(hash_keys)

return row_batch
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
license="Apache-2.0",
packages=setuptools.find_packages(),
include_package_data=True,
install_requires=["grpcio>=1.22.0", "grpcio-tools>=1.22.0", "requests>=2.22.0", "ujson>=1.35"],
install_requires=["grpcio>=1.22.0", "grpcio-tools>=1.22.0", "requests>=2.22.0", "ujson>=1.35", "mmh3==2.3.1"],
classifiers=[
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
Expand Down

0 comments on commit 73ba196

Please sign in to comment.