Skip to content

Commit

Permalink
fix: don't log an error during expected exception in metrics file writer
Browse files Browse the repository at this point in the history
  • Loading branch information
danabens committed Jun 15, 2020
1 parent 2f39d8e commit 7ad1b97
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/smexperiments/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ def log_metric(self, metric_name, value, timestamp=None, iteration_number=None):
logging.debug("Writing metric: %s", raw_metric_data)
self._file.write(json.dumps(raw_metric_data.to_record()))
self._file.write("\n")
except AttributeError as e:
logging.error(e)
except AttributeError:
if self._closed:
raise SageMakerMetricsWriterException("log_metric called on a closed writer")
elif not self._file:
Expand Down Expand Up @@ -84,7 +83,9 @@ def __del__(self):

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


class SageMakerMetricsWriterException(Exception):
Expand Down

0 comments on commit 7ad1b97

Please sign in to comment.