未验证 提交 34b4085b 编写于 作者: 走神的阿圆's avatar 走神的阿圆 提交者: GitHub

add csv format of scalar (#893)

上级 13fae54d
......@@ -122,10 +122,10 @@ class Api(object):
key = os.path.join('data/plugin/scalars/scalars', run, tag)
return self._get_with_retry(key, lib.get_scalar, run, tag)
@result('text/tab-separated-values')
def scalar_data(self, run, tag):
key = os.path.join('data/plugin/scalars/data', run, tag)
return self._get_with_retry(key, lib.get_scalar_data, run, tag)
@result('text/csv')
def scalar_data(self, run, tag, type='tsv'):
key = os.path.join('data/plugin/scalars/data', run, tag, type)
return self._get_with_retry(key, lib.get_scalar_data, run, tag, type)
@result()
def image_list(self, mode, tag):
......@@ -222,7 +222,7 @@ def create_api_call(logdir, model, cache_timeout):
'pr-curve/tags': (api.pr_curve_tags, []),
'roc-curve/tags': (api.roc_curve_tags, []),
'scalar/list': (api.scalar_list, ['run', 'tag']),
'scalar/data': (api.scalar_data, ['run', 'tag']),
'scalar/data': (api.scalar_data, ['run', 'tag', 'type']),
'image/list': (api.image_list, ['run', 'tag']),
'image/image': (api.image_image, ['run', 'tag', 'index']),
'audio/list': (api.audio_list, ['run', 'tag']),
......
......@@ -125,12 +125,13 @@ def get_scalar(log_reader, run, tag):
return results
def get_scalar_data(log_reader, run, tag):
def get_scalar_data(log_reader, run, tag, type='tsv'):
run = log_reader.name2tags[run] if run in log_reader.name2tags else run
log_reader.load_new_data()
result = log_reader.get_log_data('scalar', run, tag)
delimeter = '\t' if 'tsv' == type else ','
with io.StringIO() as fp:
csv_writer = csv.writer(fp, delimiter='\t')
csv_writer = csv.writer(fp, delimiter=delimeter)
csv_writer.writerow(['id', 'tag', 'timestamp', 'value'])
csv_writer.writerows(result)
result = fp.getvalue()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册