From 24fbc921773d10e2664be11ab4abb28bd8d25b0b Mon Sep 17 00:00:00 2001 From: Evaline Ju <69598118+evaline-ju@users.noreply.github.com> Date: Fri, 16 Aug 2024 12:46:07 -0600 Subject: [PATCH] :goal_net: Handle non-connection errors Signed-off-by: Evaline Ju <69598118+evaline-ju@users.noreply.github.com> --- .../toolkit/text_generation/tgis_utils.py | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/caikit_nlp/toolkit/text_generation/tgis_utils.py b/caikit_nlp/toolkit/text_generation/tgis_utils.py index 675877d8..724773ed 100644 --- a/caikit_nlp/toolkit/text_generation/tgis_utils.py +++ b/caikit_nlp/toolkit/text_generation/tgis_utils.py @@ -476,13 +476,17 @@ def unary_generate( request, timeout=self.tgis_req_timeout ) except grpc._channel._InactiveRpcError as err: - log.error("", err.details()) + details = err.details() + log.error("", 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 + else: + raise CaikitCoreException(caikit_status_code, details) from err except grpc.RpcError as err: raise_caikit_core_exception(err) @@ -663,13 +667,17 @@ def stream_generate( details=details, ) except grpc._channel._InactiveRpcError as err: - log.error("", err.details()) + details = err.details() + log.error("", 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 + else: + raise CaikitCoreException(caikit_status_code, details) from err except grpc.RpcError as err: raise_caikit_core_exception(err)