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

check file before uploading to server (#866)

上级 e6bda9c9
......@@ -22,18 +22,28 @@ from visualdl.proto import record_pb2
from visualdl.utils.string_util import decode_tag, encode_tag
def is_VDLRecord_file(path):
def is_VDLRecord_file(path, check=False):
"""Determine whether it is a VDL log file according to the file name.
File name of a VDL log file must contain `vdlrecords`.
Args:
path: File name to determine.
check: Check file is valid or not.
Returns:
True if the file is a VDL log file, otherwise false.
"""
return "vdlrecords" in path
if not "vdlrecords" in path:
return False
if check:
_reader = RecordReader(filepath=path)
meta_data = _reader.get_next()
record = record_pb2.Record()
record.ParseFromString(meta_data)
if 'meta_data_tag' != record.values[0].tag:
return False
return True
class LogReader(object):
......
......@@ -69,7 +69,8 @@ def get_vdl_log_file(logdirs):
walks_temp = {}
for run, tags in walks.items():
tags_temp = [tag for tag in tags if is_VDLRecord_file(tag)]
tags_temp = [tag for tag in tags if
is_VDLRecord_file(path=bfile.join(run, tag), check=True)]
tags_temp.sort(reverse=True)
if len(tags_temp) > 0:
walks_temp.update({run: tags_temp[0]})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册