-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Milvus error handling #292
Changes from all commits
0dca8ec
6b1a05a
ee6000a
4f43b4a
d841bef
4dd4d30
d80aa04
4e459db
546c72b
ca0371b
5287adf
37424e2
208a6e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "0.3.12-dev3" # pragma: no cover | ||
__version__ = "0.3.12-dev4" # pragma: no cover |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,11 +156,18 @@ class MilvusUploader(Uploader): | |
|
||
@DestinationConnectionError.wrap | ||
def precheck(self): | ||
with self.get_client() as client: | ||
if not client.has_collection(self.upload_config.collection_name): | ||
raise DestinationConnectionError( | ||
f"Collection '{self.upload_config.collection_name}' does not exist" | ||
) | ||
from pymilvus import MilvusException | ||
|
||
try: | ||
with self.get_client() as client: | ||
if not client.has_collection(self.upload_config.collection_name): | ||
raise DestinationConnectionError( | ||
f"Collection '{self.upload_config.collection_name}' does not exist" | ||
) | ||
except MilvusException as milvus_exception: | ||
raise DestinationConnectionError( | ||
f"failed to precheck Milvus: {str(milvus_exception.message)}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have to use
|
||
) from milvus_exception | ||
|
||
@contextmanager | ||
def get_client(self) -> Generator["MilvusClient", None, None]: | ||
|
@@ -197,7 +204,9 @@ def insert_results(self, data: Union[dict, list[dict]]): | |
try: | ||
res = client.insert(collection_name=self.upload_config.collection_name, data=data) | ||
except MilvusException as milvus_exception: | ||
raise WriteError("failed to upload records to milvus") from milvus_exception | ||
raise WriteError( | ||
f"failed to upload records to Milvus: {str(milvus_exception.message)}" | ||
) from milvus_exception | ||
if "err_count" in res and isinstance(res["err_count"], int) and res["err_count"] > 0: | ||
err_count = res["err_count"] | ||
raise WriteError(f"failed to upload {err_count} docs") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without it was getting