Skip to content
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

🥅 Handle error details on inactive rpc errors #384

Merged
merged 3 commits into from
Aug 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions caikit_nlp/toolkit/text_generation/tgis_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,13 +476,16 @@ def unary_generate(
request, timeout=self.tgis_req_timeout
)
except grpc._channel._InactiveRpcError as err:
log.error("<NLP30829218E>", err.details)
details = err.details()
log.error("<NLP30829218E>", details)
caikit_status_code = GRPC_TO_CAIKIT_CORE_STATUS.get(
err.code(), CaikitCoreStatusCode.UNKNOWN
)
raise CaikitCoreException(
caikit_status_code, INACTIVE_RPC_CONN_ERR_MESSAGE
) from err
if caikit_status_code == CaikitCoreStatusCode.CONNECTION_ERROR:
raise CaikitCoreException(
caikit_status_code, INACTIVE_RPC_CONN_ERR_MESSAGE
) from err
raise CaikitCoreException(caikit_status_code, details) from err
except grpc.RpcError as err:
raise_caikit_core_exception(err)

Expand Down Expand Up @@ -663,13 +666,16 @@ def stream_generate(
details=details,
)
except grpc._channel._InactiveRpcError as err:
log.error("<NLP11829118E>", err.details)
details = err.details()
log.error("<NLP11829118E>", details)
caikit_status_code = GRPC_TO_CAIKIT_CORE_STATUS.get(
err.code(), CaikitCoreStatusCode.UNKNOWN
)
raise CaikitCoreException(
caikit_status_code, INACTIVE_RPC_CONN_ERR_MESSAGE
) from err
if caikit_status_code == CaikitCoreStatusCode.CONNECTION_ERROR:
raise CaikitCoreException(
caikit_status_code, INACTIVE_RPC_CONN_ERR_MESSAGE
) from err
raise CaikitCoreException(caikit_status_code, details) from err
except grpc.RpcError as err:
raise_caikit_core_exception(err)

Expand Down
Loading