Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
VisualDL
提交
3e8604ba
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看板
未验证
提交
3e8604ba
编写于
6月 11, 2020
作者:
走神的阿圆
提交者:
GitHub
6月 11, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add --model to parameters. (#661)
* Add --model to parameters.
上级
2b9e8c65
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
48 addition
and
7 deletion
+48
-7
visualdl/reader/reader.py
visualdl/reader/reader.py
+19
-2
visualdl/server/api.py
visualdl/server/api.py
+11
-4
visualdl/server/app.py
visualdl/server/app.py
+2
-1
visualdl/server/args.py
visualdl/server/args.py
+8
-0
visualdl/server/lib.py
visualdl/server/lib.py
+8
-0
未找到文件。
visualdl/reader/reader.py
浏览文件 @
3e8604ba
...
...
@@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# =======================================================================
import
os
from
visualdl.io
import
bfile
from
visualdl.component
import
components
from
visualdl.reader.record_reader
import
RecordReader
...
...
@@ -61,6 +62,22 @@ class LogReader(object):
self
.
load_new_data
(
update
=
True
)
self
.
_a_tags
=
{}
self
.
_model
=
""
@
property
def
model
(
self
):
return
self
.
_model
@
model
.
setter
def
model
(
self
,
model_path
):
if
not
os
.
path
.
isfile
(
model_path
):
print
(
"Model path %s should be file path, please check this path."
%
model_path
)
else
:
if
os
.
path
.
exists
(
model_path
):
self
.
_model
=
model_path
else
:
print
(
"Model path %s is invalid, please check this path."
%
model_path
)
@
property
def
logdir
(
self
):
return
self
.
dir
...
...
@@ -213,8 +230,8 @@ class LogReader(object):
if
update
is
True
:
self
.
load_new_data
(
update
=
update
)
components_set
=
set
(
self
.
_tags
.
values
())
if
0
==
len
(
components_set
):
return
{
'scalar'
}
components_set
.
add
(
'scalar'
)
return
components_set
def
load_new_data
(
self
,
update
=
True
):
...
...
visualdl/server/api.py
浏览文件 @
3e8604ba
...
...
@@ -57,8 +57,9 @@ def try_call(function, *args, **kwargs):
class
Api
(
object
):
def
__init__
(
self
,
logdir
,
cache_timeout
):
def
__init__
(
self
,
logdir
,
model
,
cache_timeout
):
self
.
_reader
=
LogReader
(
logdir
)
self
.
_reader
.
model
=
model
# use a memory cache to reduce disk reading frequency.
cache
=
MemCache
(
timeout
=
cache_timeout
)
...
...
@@ -144,9 +145,14 @@ class Api(object):
key
=
os
.
path
.
join
(
'data/plugin/embeddings/embeddings'
,
run
,
tag
)
return
self
.
_get_with_retry
(
key
,
lib
.
get_embeddings
,
run
,
tag
)
@
result
(
'application/octet-stream'
)
def
graphs_graph
(
self
):
key
=
os
.
path
.
join
(
'data/plugin/graphs/graph'
)
return
self
.
_get_with_retry
(
key
,
lib
.
get_graph
)
def
create_api_call
(
logdir
,
cache_timeout
):
api
=
Api
(
logdir
,
cache_timeout
)
def
create_api_call
(
logdir
,
model
,
cache_timeout
):
api
=
Api
(
logdir
,
model
,
cache_timeout
)
routes
=
{
'components'
:
(
api
.
components
,
[]),
'runs'
:
(
api
.
runs
,
[]),
...
...
@@ -163,7 +169,8 @@ def create_api_call(logdir, cache_timeout):
'audio/list'
:
(
api
.
audio_list
,
[
'run'
,
'tag'
]),
'audio/audio'
:
(
api
.
audio_audio
,
[
'run'
,
'tag'
,
'index'
]),
'embeddings/embedding'
:
(
api
.
embeddings_embedding
,
[
'run'
,
'tag'
,
'reduction'
,
'dimension'
]),
'histogram/histogram'
:
(
api
.
histogram_histogram
,
[
'run'
,
'tag'
])
'histogram/histogram'
:
(
api
.
histogram_histogram
,
[
'run'
,
'tag'
]),
'graphs/graph'
:
(
api
.
graphs_graph
,
[])
}
def
call
(
path
:
str
,
args
):
...
...
visualdl/server/app.py
浏览文件 @
3e8604ba
...
...
@@ -52,7 +52,7 @@ def create_app(args):
app
.
config
[
'BABEL_DEFAULT_LOCALE'
]
=
default_language
babel
=
Babel
(
app
)
api_call
=
create_api_call
(
args
.
logdir
,
args
.
cache_timeout
)
api_call
=
create_api_call
(
args
.
logdir
,
args
.
model
,
args
.
cache_timeout
)
update_util
.
PbUpdater
().
start
()
...
...
@@ -100,6 +100,7 @@ def create_app(args):
def
serve_api
(
method
):
data
,
mimetype
=
api_call
(
method
,
request
.
args
)
return
make_response
(
Response
(
data
,
mimetype
=
mimetype
))
return
app
...
...
visualdl/server/args.py
浏览文件 @
3e8604ba
...
...
@@ -77,6 +77,7 @@ class ParseArgs(object):
self
.
public_path
=
args
.
public_path
self
.
api_only
=
args
.
api_only
self
.
open_browser
=
args
.
open_browser
self
.
model
=
args
.
model
def
parse_args
():
...
...
@@ -105,6 +106,13 @@ def parse_args():
default
=
default_host
,
action
=
"store"
,
help
=
"api service ip"
)
parser
.
add_argument
(
"--model"
,
type
=
str
,
action
=
"store"
,
dest
=
"model"
,
default
=
""
,
help
=
"model file path"
)
parser
.
add_argument
(
"--cache_timeout"
,
action
=
"store"
,
...
...
visualdl/server/lib.py
浏览文件 @
3e8604ba
...
...
@@ -155,6 +155,14 @@ def get_histogram(log_reader, run, tag):
return
results
def
get_graph
(
log_reader
):
result
=
b
""
if
log_reader
.
model
:
with
open
(
log_reader
.
model
,
"rb"
)
as
fp
:
result
=
fp
.
read
()
return
result
def
retry
(
ntimes
,
function
,
time2sleep
,
*
args
,
**
kwargs
):
'''
try to execute `function` `ntimes`, if exception catched, the thread will
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录