Commit 82a25a31 authored by Scott Zhu's avatar Scott Zhu
Browse files

Update logger value type and test

1. Update logger to convert the value type to float to please JSON.
2. Update logger test to call parent test tearDown.
parent ff17f5dd
......@@ -60,12 +60,16 @@ class BenchmarkLogger(object):
os.path.join(self._logging_dir, _METRIC_LOG_FILE_NAME), "a") as f:
metric = {
"name": name,
"value": value,
"value": float(value),
"unit": unit,
"global_step": global_step,
"timestamp": datetime.datetime.now().strftime(
_DATE_TIME_FORMAT_PATTERN),
"extras": extras}
try:
json.dump(metric, f)
f.write("\n")
except (TypeError, ValueError) as e:
tf.logging.warning("Failed to dump metric to log file: name %s, value %s, error %s",
name, value, e)
......@@ -32,6 +32,7 @@ import tensorflow as tf
class BenchmarkLoggerTest(tf.test.TestCase):
def tearDown(self):
super(BenchmarkLoggerTest, self).tearDown()
tf.gfile.DeleteRecursively(self.get_temp_dir())
def test_create_logging_dir(self):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment