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

add VISUALDL_RUN_PREFIX (#818)

* add VISUALDL_RUN_PREFIX

* fix review

* simplify logi
Co-authored-by: Nwuzewu <wuzewu@baidu.com>
上级 3b752417
......@@ -16,12 +16,17 @@
from __future__ import absolute_import
import sys
import time
import os
import numpy as np
from visualdl.server.log import logger
from visualdl.io import bfile
from visualdl.utils.string_util import encode_tag, decode_tag
MODIFY_PREFIX = {}
MODIFIED_RUNS = []
def s2ms(timestamp):
return timestamp * 1000 if timestamp < 2000000000 else timestamp
......@@ -57,6 +62,9 @@ def get_logs(log_reader, component):
tags[run].append(tag)
else:
tags[run] = [tag]
if run not in log_reader.tags2name.keys():
log_reader.tags2name[run] = run
log_reader.name2tags[run] = run
fake_tags = {}
for key, value in tags.items():
if key in log_reader.tags2name:
......@@ -69,6 +77,32 @@ def get_logs(log_reader, component):
run2tag['runs'].append(run)
run2tag['tags'].append(tags)
run_prefix = os.getenv('VISUALDL_RUN_PREFIX')
global MODIFY_PREFIX, MODIFIED_RUNS
if component not in MODIFY_PREFIX:
MODIFY_PREFIX.update({component: False})
if run_prefix and not MODIFY_PREFIX[component]:
MODIFY_PREFIX[component] = True
temp_name2tags = log_reader.name2tags.copy()
for key, value in temp_name2tags.items():
if key in MODIFIED_RUNS:
continue
index = key.find(run_prefix)
if index != -1:
temp_key = key[index+len(run_prefix):]
log_reader.name2tags.pop(key)
log_reader.name2tags.update({temp_key: value})
log_reader.tags2name.pop(value)
log_reader.tags2name.update({value: temp_key})
run2tag['runs'][run2tag['runs'].index(key)] = temp_key
else:
temp_key = key
MODIFIED_RUNS.append(temp_key)
return run2tag
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册