Skip to content

Commit 7ad1b97

Browse files
committed
fix: don't log an error during expected exception in metrics file writer
1 parent 2f39d8e commit 7ad1b97

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/smexperiments/metrics.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ def log_metric(self, metric_name, value, timestamp=None, iteration_number=None):
5252
logging.debug("Writing metric: %s", raw_metric_data)
5353
self._file.write(json.dumps(raw_metric_data.to_record()))
5454
self._file.write("\n")
55-
except AttributeError as e:
56-
logging.error(e)
55+
except AttributeError:
5756
if self._closed:
5857
raise SageMakerMetricsWriterException("log_metric called on a closed writer")
5958
elif not self._file:
@@ -84,7 +83,9 @@ def __del__(self):
8483

8584
def _get_metrics_file_path(self):
8685
pid_filename = "{}.json".format(str(os.getpid()))
87-
return self._metrics_file_path or os.path.join(METRICS_DIR, pid_filename)
86+
metrics_file_path = self._metrics_file_path or os.path.join(METRICS_DIR, pid_filename)
87+
logging.debug("metrics_file_path=" + metrics_file_path)
88+
return metrics_file_path
8889

8990

9091
class SageMakerMetricsWriterException(Exception):

0 commit comments

Comments
 (0)