diff --git a/visualdl/server/api.py b/visualdl/server/api.py index d114f7f3436b8a994e10136c1a972489893ad211..a0abe6ef668fdc7472f6bfbd6dff865853974bbc 100644 --- a/visualdl/server/api.py +++ b/visualdl/server/api.py @@ -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']), diff --git a/visualdl/server/lib.py b/visualdl/server/lib.py index 960651874666d09746246a7223a01b67eda68c36..e46026473fa55b19dca9ef0321b826a0b8e6e474 100644 --- a/visualdl/server/lib.py +++ b/visualdl/server/lib.py @@ -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()