From 45590cc7163b7142c40597eac2248ee17afb3d3d Mon Sep 17 00:00:00 2001 From: Chris Cummins Date: Tue, 22 Feb 2022 08:35:16 -0800 Subject: [PATCH] [service] Reduce severity of logging messages on reset() retry. --- compiler_gym/envs/compiler_env.py | 9 ++++++++- compiler_gym/service/connection.py | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/compiler_gym/envs/compiler_env.py b/compiler_gym/envs/compiler_env.py index fce35565e8..62b7f29fe6 100644 --- a/compiler_gym/envs/compiler_env.py +++ b/compiler_gym/envs/compiler_env.py @@ -735,7 +735,14 @@ def reset( # pylint: disable=arguments-differ def _retry(error) -> Optional[ObservationType]: """Abort and retry on error.""" - logger.warning("%s during reset(): %s", type(error).__name__, error) + # Log the error that we are recovering from, but treat + # ServiceIsClosed errors as unimportant since we know what causes + # them. + log_severity = ( + logger.debug if isinstance(error, ServiceIsClosed) else logger.warning + ) + log_severity("%s during reset(): %s", type(error).__name__, error) + if self.service: try: self.service.close() diff --git a/compiler_gym/service/connection.py b/compiler_gym/service/connection.py index 16257d48b7..8f92957818 100644 --- a/compiler_gym/service/connection.py +++ b/compiler_gym/service/connection.py @@ -204,7 +204,7 @@ def __call__( except ValueError as e: if str(e) == "Cannot invoke RPC on closed channel!": raise ServiceIsClosed( - f"RPC communication failed with message: {e}" + "RPC communication failed because channel is closed" ) from None raise e except grpc.RpcError as e: