Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
5f9ae294
S
Serving
项目概览
PaddlePaddle
/
Serving
大约 1 年 前同步成功
通知
185
Star
833
Fork
253
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
105
列表
看板
标记
里程碑
合并请求
10
Wiki
2
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Serving
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
105
Issue
105
列表
看板
标记
里程碑
合并请求
10
合并请求
10
Pages
分析
分析
仓库分析
DevOps
Wiki
2
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5f9ae294
编写于
4月 02, 2020
作者:
B
barrierye
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make error info friendly
上级
13e3b8cc
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
19 addition
and
20 deletion
+19
-20
python/paddle_serving_server/monitor.py
python/paddle_serving_server/monitor.py
+19
-20
未找到文件。
python/paddle_serving_server/monitor.py
浏览文件 @
5f9ae294
...
@@ -67,6 +67,10 @@ class Monitor(object):
...
@@ -67,6 +67,10 @@ class Monitor(object):
def
set_unpacked_filename
(
self
,
unpacked_filename
):
def
set_unpacked_filename
(
self
,
unpacked_filename
):
self
.
_unpacked_filename
=
unpacked_filename
self
.
_unpacked_filename
=
unpacked_filename
def
_check_param_help
(
self
,
param_name
,
param_value
):
return
"Please check the {}({}) parameter."
.
format
(
param_name
,
param_value
)
def
_check_params
(
self
):
def
_check_params
(
self
):
if
self
.
_remote_path
is
None
:
if
self
.
_remote_path
is
None
:
raise
Exception
(
'remote_path not set.'
)
raise
Exception
(
'remote_path not set.'
)
...
@@ -85,34 +89,26 @@ class Monitor(object):
...
@@ -85,34 +89,26 @@ class Monitor(object):
def
_decompress_model_file
(
self
,
local_tmp_path
,
model_name
,
def
_decompress_model_file
(
self
,
local_tmp_path
,
model_name
,
unpacked_filename
):
unpacked_filename
):
import
sys
print
(
unpacked_filename
)
sys
.
stdout
.
flush
()
if
unpacked_filename
is
None
:
if
unpacked_filename
is
None
:
return
model_name
return
model_name
tar_model_path
=
os
.
path
.
join
(
local_tmp_path
,
model_name
)
tar_model_path
=
os
.
path
.
join
(
local_tmp_path
,
model_name
)
print
(
tar_model_path
)
sys
.
stdout
.
flush
()
if
not
tarfile
.
is_tarfile
(
tar_model_path
):
if
not
tarfile
.
is_tarfile
(
tar_model_path
):
raise
Exception
(
raise
Exception
(
'not a tar packaged file type. {}'
.
format
(
'the model({}) of remote production is not a tar packaged file type.'
.
self
.
_check_param_help
(
'remote_model_name'
,
model_name
)))
format
(
tar_model_path
))
try
:
try
:
tar
=
tarfile
.
open
(
tar_model_path
)
tar
=
tarfile
.
open
(
tar_model_path
)
tar
.
extractall
(
local_tmp_path
)
tar
.
extractall
(
local_tmp_path
)
tar
.
close
()
tar
.
close
()
print
(
'ok'
)
sys
.
stdout
.
flush
()
except
:
except
:
raise
Exception
(
raise
Exception
(
'Decompressing failed,
please check your permission of {} or disk space left.'
.
'Decompressing failed,
maybe no disk space left. {}'
.
foemat
(
foemat
(
local_tmp_path
))
self
.
_check_param_help
(
'local_tmp_path'
,
local_tmp_path
)
))
finally
:
finally
:
os
.
remove
(
tar_model_path
)
os
.
remove
(
tar_model_path
)
if
not
os
.
path
.
exists
(
unpacked_filename
):
if
not
os
.
path
.
exists
(
unpacked_filename
):
raise
Exception
(
raise
Exception
(
'file not exist. {}'
.
format
(
'{} not exists. Please check the unpacked_filename parameter.'
.
self
.
_check_param_help
(
'unpacked_filename'
,
format
(
unpacked_filename
))
unpacked_filename
)
))
return
unpacked_filename
return
unpacked_filename
def
run
(
self
):
def
run
(
self
):
...
@@ -215,7 +211,8 @@ class AFSMonitor(Monitor):
...
@@ -215,7 +211,8 @@ class AFSMonitor(Monitor):
cmd
=
'{} -get {} {}'
.
format
(
self
.
_cmd_prefix
,
remote_dirpath
,
cmd
=
'{} -get {} {}'
.
format
(
self
.
_cmd_prefix
,
remote_dirpath
,
local_dirpath
)
local_dirpath
)
if
os
.
system
(
cmd
)
!=
0
:
if
os
.
system
(
cmd
)
!=
0
:
raise
Exception
(
'pull remote dir failed.'
)
raise
Exception
(
'pull remote dir failed. {}'
.
format
(
self
.
_check_param_help
(
'remote_model_name'
,
dirname
)))
class
HDFSMonitor
(
Monitor
):
class
HDFSMonitor
(
Monitor
):
...
@@ -240,7 +237,8 @@ class HDFSMonitor(Monitor):
...
@@ -240,7 +237,8 @@ class HDFSMonitor(Monitor):
cmd
=
'{} -get -f {} {}'
.
format
(
self
.
_prefix_cmd
,
remote_dirpath
,
cmd
=
'{} -get -f {} {}'
.
format
(
self
.
_prefix_cmd
,
remote_dirpath
,
local_tmp_path
)
local_tmp_path
)
if
os
.
system
(
cmd
)
!=
0
:
if
os
.
system
(
cmd
)
!=
0
:
raise
Exception
(
'pull remote dir failed.'
)
raise
Exception
(
'pull remote dir failed. {}'
.
format
(
self
.
_check_param_help
(
'remote_model_name'
,
dirname
)))
class
FTPMonitor
(
Monitor
):
class
FTPMonitor
(
Monitor
):
...
@@ -326,7 +324,7 @@ class GeneralMonitor(Monitor):
...
@@ -326,7 +324,7 @@ class GeneralMonitor(Monitor):
def
_exist_remote_file
(
self
,
path
,
filename
,
local_tmp_path
):
def
_exist_remote_file
(
self
,
path
,
filename
,
local_tmp_path
):
remote_filepath
=
os
.
path
.
join
(
path
,
filename
)
remote_filepath
=
os
.
path
.
join
(
path
,
filename
)
url
=
'{}/{}'
.
format
(
self
.
_host
,
remote_filepath
)
url
=
'{}/{}'
.
format
(
self
.
_host
,
remote_filepath
)
cmd
=
'wget -N -P {} {}'
.
format
(
local_tmp_path
,
url
)
cmd
=
'wget -N -P {} {}
&>/dev/null
'
.
format
(
local_tmp_path
,
url
)
if
os
.
system
(
cmd
)
!=
0
:
if
os
.
system
(
cmd
)
!=
0
:
return
[
False
,
None
]
return
[
False
,
None
]
else
:
else
:
...
@@ -337,9 +335,10 @@ class GeneralMonitor(Monitor):
...
@@ -337,9 +335,10 @@ class GeneralMonitor(Monitor):
def
_pull_remote_dir
(
self
,
remote_path
,
dirname
,
local_tmp_path
):
def
_pull_remote_dir
(
self
,
remote_path
,
dirname
,
local_tmp_path
):
remote_dirpath
=
os
.
path
.
join
(
remote_path
,
dirname
)
remote_dirpath
=
os
.
path
.
join
(
remote_path
,
dirname
)
url
=
'{}/{}'
.
format
(
self
.
_host
,
remote_dirpath
)
url
=
'{}/{}'
.
format
(
self
.
_host
,
remote_dirpath
)
cmd
=
'wget -nH -r -P {} {} &>
/dev/null'
.
format
(
local_tmp_path
,
url
)
cmd
=
'wget -nH -r -P {} {} &>/dev/null'
.
format
(
local_tmp_path
,
url
)
if
os
.
system
(
cmd
)
!=
0
:
if
os
.
system
(
cmd
)
!=
0
:
raise
Exception
(
'pull remote dir failed.'
)
raise
Exception
(
'pull remote dir failed. {}'
.
format
(
self
.
_check_param_help
(
'remote_model_name'
,
dirname
)))
def
parse_args
():
def
parse_args
():
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录