From be2edc448f681daada61e770951341268e4a4851 Mon Sep 17 00:00:00 2001 From: ShenYuhan Date: Thu, 18 Jun 2020 17:21:36 +0800 Subject: [PATCH] Fix bugs (#669) * Fix warning for hdfs * Update docs. --- README.md | 2 ++ docs/overview.md | 2 ++ requirements.txt | 2 +- visualdl/io/bfile.py | 13 +++++++------ visualdl/server/api.py | 3 ++- visualdl/server/args.py | 8 ++++++++ visualdl/version.py | 2 +- 7 files changed, 23 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 0c73f98a..f67597ff 100644 --- a/README.md +++ b/README.md @@ -136,6 +136,7 @@ visualdl --logdir --host --port --cach | 参数 | 意义 | | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | --logdir | 设定日志所在目录,可以指定多个目录,VisualDL将遍历并且迭代寻找指定目录的子目录,将所有实验结果进行可视化 | +| --model | 设定模型文件路径(非文件夹路径),VisualDL将在此路径指定的模型文件进行可视化,目前可支持PaddlePaddle、ONNX、Keras、Core ML、Caffe等多种模型结构,详情可查看[graph支持模型种类](./docs/components/README.md#%E5%8A%9F%E8%83%BD%E6%93%8D%E4%BD%9C%E8%AF%B4%E6%98%8E-2) | | --host | 设定IP,默认为`127.0.0.1` | | --port | 设定端口,默认为`8040` | | --cache-timeout | 后端缓存时间,在缓存时间内前端多次请求同一url,返回的数据从缓存中获取,默认为20秒 | @@ -171,6 +172,7 @@ visualdl.server.app.run(logdir, | 参数 | 格式 | 含义 | | ------------- | ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | logdir | string或list[string_1, string_2, ... , string_n] | 日志文件所在的路径,VisualDL将在此路径下递归搜索日志文件并进行可视化,可指定单个或多个路径 | +| model | string | 模型文件路径(非文件夹路径),VisualDL将在此路径指定的模型文件进行可视化 | | host | string | 指定启动服务的ip,默认为`127.0.0.1` | | port | int | 启动服务端口,默认为`8040` | | cache_timeout | int | 后端缓存时间,在缓存时间内前端多次请求同一url,返回的数据从缓存中获取,默认为20秒 | diff --git a/docs/overview.md b/docs/overview.md index 7c1ba46e..3d9c7132 100644 --- a/docs/overview.md +++ b/docs/overview.md @@ -122,6 +122,7 @@ visualdl --logdir --host --port --cach | 参数 | 意义 | | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | --logdir | 设定日志所在目录,可以指定多个目录,VisualDL将遍历并且迭代寻找指定目录的子目录,将所有实验结果进行可视化 | +| --model | 设定模型文件路径(非文件夹路径),VisualDL将在此路径指定的模型文件进行可视化,目前可支持PaddlePaddle、ONNX、Keras、Core ML、Caffe等多种模型结构,详情可查看[graph支持模型种类](./components/README.md#%E5%8A%9F%E8%83%BD%E6%93%8D%E4%BD%9C%E8%AF%B4%E6%98%8E-2) | | --host | 设定IP,默认为`127.0.0.1` | | --port | 设定端口,默认为`8040` | | --cache-timeout | 后端缓存时间,在缓存时间内前端多次请求同一url,返回的数据从缓存中获取,默认为20秒 | @@ -155,6 +156,7 @@ visualdl.server.app.run(logdir, | 参数 | 格式 | 含义 | | ------------- | ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | logdir | string或list[string_1, string_2, ... , string_n] | 日志文件所在的路径,VisualDL将在此路径下递归搜索日志文件并进行可视化,可指定单个或多个路径 | +| model | string | 模型文件路径(非文件夹路径),VisualDL将在此路径指定的模型文件进行可视化 | | host | string | 指定启动服务的ip,默认为`127.0.0.1` | | port | int | 启动服务端口,默认为`8040` | | cache_timeout | int | 后端缓存时间,在缓存时间内前端多次请求同一url,返回的数据从缓存中获取,默认为20秒 | diff --git a/requirements.txt b/requirements.txt index afafa10a..588778c2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,6 +6,6 @@ pre-commit flask >= 1.1.1 Flask-Babel >= 1.0.0 six >= 1.14.0 -protobuf >= 3.1.0 +protobuf >= 3.11.0 opencv-python hdfs diff --git a/visualdl/io/bfile.py b/visualdl/io/bfile.py index e7a7bdbb..6545fec7 100644 --- a/visualdl/io/bfile.py +++ b/visualdl/io/bfile.py @@ -31,6 +31,13 @@ class FileFactory(object): self._register_factories.update({path: filesystem}) def get_filesystem(self, path): + if path.startswith( + 'hdfs://') and "hdfs" not in self._register_factories: + try: + default_file_factory.register_filesystem("hdfs", HDFileSystem()) + except hdfs.util.HdfsError: + raise RuntimeError( + "Please initialize `~/.hdfscli.cfg` for HDFS.") prefix = "" index = path.find("://") if index >= 0: @@ -130,12 +137,6 @@ class HDFileSystem(object): return (['hdfs://'+root, dirs, files] for root, dirs, files in walks) -try: - default_file_factory.register_filesystem("hdfs", HDFileSystem()) -except hdfs.util.HdfsError: - print("HDFS initialization failed, please check if .hdfscli,cfg exists.") - - class BFile(object): def __init__(self, filename, mode): if mode not in ('r', 'rb', 'br', 'w', 'wb', 'bw'): diff --git a/visualdl/server/api.py b/visualdl/server/api.py index 43143de7..90228f3e 100644 --- a/visualdl/server/api.py +++ b/visualdl/server/api.py @@ -63,7 +63,8 @@ def try_call(function, *args, **kwargs): class Api(object): def __init__(self, logdir, model, cache_timeout): self._reader = LogReader(logdir) - self._reader.model = model + if model: + self._reader.model = model self.model_name = os.path.basename(model) # use a memory cache to reduce disk reading frequency. diff --git a/visualdl/server/args.py b/visualdl/server/args.py index a298d24e..cf43fc30 100644 --- a/visualdl/server/args.py +++ b/visualdl/server/args.py @@ -35,6 +35,7 @@ class DefaultArgs(object): self.public_path = args.get('public_path') self.api_only = args.get('api_only', False) self.open_browser = args.get('open_browser', False) + self.model = args.get('model', '') def validate_args(args): @@ -142,6 +143,13 @@ def parse_args(): default=False, help="serve api only" ) + parser.add_argument( + "-B", + "--open_browser", + action="store_true", + default=False, + help="open browser automatically" + ) args = parser.parse_args() diff --git a/visualdl/version.py b/visualdl/version.py index c66cfb9c..1128e80e 100644 --- a/visualdl/version.py +++ b/visualdl/version.py @@ -13,4 +13,4 @@ # limitations under the License. # ======================================================================= -vdl_version = '2.0.0-beta.6' +vdl_version = '2.0.0-beta.7' -- GitLab