Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
VisualDL
提交
aebaffd2
V
VisualDL
项目概览
PaddlePaddle
/
VisualDL
大约 1 年 前同步成功
通知
88
Star
4655
Fork
642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
5
Wiki
分析
仓库
DevOps
项目成员
Pages
V
VisualDL
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
5
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
aebaffd2
编写于
5月 16, 2020
作者:
走神的阿圆
提交者:
GitHub
5月 16, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Pb check and update. (#630)
上级
951dcbd3
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
68 addition
and
3 deletion
+68
-3
visualdl/server/app.py
visualdl/server/app.py
+5
-3
visualdl/utils/update_util.py
visualdl/utils/update_util.py
+63
-0
未找到文件。
visualdl/server/app.py
浏览文件 @
aebaffd2
...
...
@@ -27,6 +27,7 @@ import webbrowser
import
requests
from
visualdl.reader.reader
import
LogReader
from
argparse
import
ArgumentParser
from
visualdl.utils
import
update_util
from
flask
import
(
Flask
,
Response
,
redirect
,
request
,
send_file
,
send_from_directory
)
from
flask_babel
import
Babel
...
...
@@ -153,7 +154,7 @@ def gen_result(status, msg, data):
return
result
def
create_app
(
args
):
def
create_app
(
args
,
method
):
app
=
Flask
(
__name__
,
static_url_path
=
""
)
# set static expires in a short time to reduce browser's memory usage.
app
.
config
[
'SEND_FILE_MAX_AGE_DEFAULT'
]
=
30
...
...
@@ -165,6 +166,7 @@ def create_app(args):
# use a memory cache to reduce disk reading frequency.
CACHE
=
MemCache
(
timeout
=
args
.
cache_timeout
)
cache_get
=
lib
.
cache_get
(
CACHE
)
update_util
.
PbUpdater
(
method
).
start
()
public_path
=
args
.
public_path
.
rstrip
(
'/'
)
api_path
=
public_path
+
'/api'
...
...
@@ -348,7 +350,7 @@ def _run(logdir,
language
=
language
,
public_path
=
public_path
)
logger
.
info
(
" port="
+
str
(
args
.
port
))
app
=
create_app
(
args
)
app
=
create_app
(
args
,
'run'
)
index_url
=
"http://"
+
host
+
":"
+
str
(
port
)
+
args
.
public_path
if
open_browser
:
threading
.
Thread
(
...
...
@@ -399,7 +401,7 @@ def main():
for
sig
in
[
signal
.
SIGINT
,
signal
.
SIGHUP
,
signal
.
SIGTERM
]:
signal
.
signal
(
sig
,
clean_template
)
logger
.
info
(
" port="
+
str
(
args
.
port
))
app
=
create_app
(
args
=
args
)
app
=
create_app
(
args
,
'main'
)
app
.
run
(
debug
=
False
,
host
=
args
.
host
,
port
=
args
.
port
,
threaded
=
False
)
...
...
visualdl/utils/update_util.py
0 → 100644
浏览文件 @
aebaffd2
# Copyright (c) 2020 VisualDL Authors. All Rights Reserve.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# =======================================================================
import
threading
import
hashlib
import
requests
import
json
from
visualdl
import
__version__
from
visualdl.proto.record_pb2
import
DESCRIPTOR
def
md5
(
text
):
if
isinstance
(
text
,
str
):
text
=
text
.
encode
(
"utf8"
)
md5
=
hashlib
.
md5
()
md5
.
update
(
text
)
return
md5
.
hexdigest
()
class
PbUpdater
(
threading
.
Thread
):
def
__init__
(
self
,
start_method
):
threading
.
Thread
.
__init__
(
self
)
self
.
start_method
=
start_method
def
update_pb
(
self
,
start_method
,
version
=
__version__
,
md5_code
=
md5
(
str
(
DESCRIPTOR
))
):
payload
=
{
"data"
:
{
"start_method"
:
start_method
,
"version"
:
version
,
"md5"
:
md5_code
}
}
url
=
'https://paddlepaddle.org.cn/paddlehub/stat?from=vdl'
try
:
r
=
requests
.
post
(
url
=
url
,
json
=
json
.
dumps
(
payload
,
sort_keys
=
True
))
if
r
.
json
().
get
(
"update_flag"
,
0
)
==
1
:
pb_bin
=
r
.
json
().
get
(
"pb_bin"
)
with
open
(
'/visualdl/proto/record_pb2.py'
,
mode
=
'wb'
)
as
fp
:
fp
.
write
(
pb_bin
)
print
(
'Update pb file successfully.'
)
except
Exception
as
err
:
pass
def
run
(
self
):
self
.
update_pb
(
start_method
=
self
.
start_method
,
version
=
__version__
,
md5_code
=
md5
(
str
(
DESCRIPTOR
))
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录