Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleHub
提交
99243e35
P
PaddleHub
项目概览
PaddlePaddle
/
PaddleHub
1 年多 前同步成功
通知
283
Star
12117
Fork
2091
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
200
列表
看板
标记
里程碑
合并请求
4
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleHub
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
200
Issue
200
列表
看板
标记
里程碑
合并请求
4
合并请求
4
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
99243e35
编写于
1月 19, 2020
作者:
走神的阿圆
提交者:
Steffy-zxf
1月 19, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify serving&config help (#330)
上级
f9254b90
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
35 addition
and
26 deletion
+35
-26
README.md
README.md
+1
-1
paddlehub/commands/config.py
paddlehub/commands/config.py
+2
-2
paddlehub/commands/serving.py
paddlehub/commands/serving.py
+32
-23
未找到文件。
README.md
浏览文件 @
99243e35
...
...
@@ -153,7 +153,7 @@ $ hub serving start --config config.json
config.json文件包含待部署模型信息等,
关于PaddleHub Serving详细信息参
考
[
PaddleHub Serving一键服务化部署
](
./tutorial/serving.md
)
。
关于PaddleHub Serving详细信息参
见
[
PaddleHub Serving一键服务化部署
](
./tutorial/serving.md
)
。
### 超参优化AutoDL Finetuner
...
...
paddlehub/commands/config.py
浏览文件 @
99243e35
...
...
@@ -90,12 +90,12 @@ class ConfigCommand(BaseCommand):
@
staticmethod
def
show_help
():
str
=
"config <option>
\n
"
str
+=
"
\t
Show
hub server
config without any option.
\n
"
str
+=
"
\t
Show
PaddleHub
config without any option.
\n
"
str
+=
"option:
\n
"
str
+=
"reset
\n
"
str
+=
"
\t
Reset config as default.
\n
"
str
+=
"server==[URL]
\n
"
str
+=
"
\t
Set
hub s
erver url as [URL].
\n
"
str
+=
"
\t
Set
PaddleHub S
erver url as [URL].
\n
"
str
+=
"log==[LEVEL]
\n
"
str
+=
"
\t
Set log level as [LEVEL:NOLOG, DEBUG, INFO, WARNING, ERROR, CRITICAL].
\n
"
print
(
str
)
...
...
paddlehub/commands/serving.py
浏览文件 @
99243e35
...
...
@@ -84,7 +84,7 @@ class ServingCommand(BaseCommand):
def
__init__
(
self
,
name
):
super
(
ServingCommand
,
self
).
__init__
(
name
)
self
.
show_in_help
=
True
self
.
description
=
"Start
a service for online predicting by using PaddleHub
."
self
.
description
=
"Start
Module Serving or Bert Service for online predicting
."
self
.
parser
=
argparse
.
ArgumentParser
(
description
=
self
.
__class__
.
__doc__
,
prog
=
'%s %s [COMMAND]'
%
(
ENTRY
,
name
),
...
...
@@ -124,7 +124,7 @@ class ServingCommand(BaseCommand):
port
=
os
.
path
.
basename
(
filepath
).
split
(
"."
)[
0
].
split
(
"_"
)[
1
]
if
not
os
.
path
.
exists
(
filepath
):
print
(
"PaddleHub
-
Serving config file is not exists, "
"PaddleHub
Serving config file is not exists, "
"please confirm the port [%s] you specified is correct."
%
port
)
return
False
with
open
(
filepath
,
"r"
)
as
fp
:
...
...
@@ -143,9 +143,9 @@ class ServingCommand(BaseCommand):
os
.
remove
(
filepath
)
if
not
pid_is_exist
(
pid
):
print
(
"PaddleHub
-
Serving has been stopped."
)
print
(
"PaddleHub
Serving has been stopped."
)
return
print
(
"PaddleHub
-
Serving will stop."
)
print
(
"PaddleHub
Serving will stop."
)
CacheUpdater
(
"hub_serving_stop"
,
module
=
module
,
...
...
@@ -160,7 +160,7 @@ class ServingCommand(BaseCommand):
@
staticmethod
def
start_bert_serving
(
args
):
if
platform
.
system
()
!=
"Linux"
:
print
(
"Error. Bert
-
Service only support linux."
)
print
(
"Error. Bert
Service only support linux."
)
return
False
if
ServingCommand
.
is_port_occupied
(
"127.0.0.1"
,
args
.
port
)
is
True
:
...
...
@@ -213,7 +213,7 @@ class ServingCommand(BaseCommand):
"category"
:
str
(
m
.
type
).
split
(
"/"
)[
0
].
upper
()
})
except
Exception
as
err
:
print
(
err
,
", start
Hub-
Serving unsuccessfully."
)
print
(
err
,
", start
PaddleHub
Serving unsuccessfully."
)
exit
(
1
)
return
configs
...
...
@@ -263,7 +263,7 @@ class ServingCommand(BaseCommand):
options
=
{
"bind"
:
"0.0.0.0:%s"
%
port
,
"workers"
:
workers
}
StandaloneApplication
(
app
.
create_app
(
init_flag
=
False
,
configs
=
configs
),
options
).
run
()
print
(
"PaddleHub
-
Serving has been stopped."
)
print
(
"PaddleHub
Serving has been stopped."
)
def
start_app_with_args
(
self
,
workers
):
module
=
self
.
args
.
modules
...
...
@@ -330,7 +330,7 @@ class ServingCommand(BaseCommand):
StandaloneApplication
(
app
.
create_app
(
init_flag
=
False
,
configs
=
configs
),
options
).
run
()
print
(
"PaddleHub
-
Serving has been stopped."
)
print
(
"PaddleHub
Serving has been stopped."
)
else
:
print
(
"Lack of necessary parameters!"
)
...
...
@@ -344,7 +344,7 @@ class ServingCommand(BaseCommand):
if
platform
.
system
()
==
"Windows"
:
print
(
"Warning: Windows cannot use multiprocess working "
"mode,
Hub-
Serving will switch to single process mode"
"mode,
PaddleHub
Serving will switch to single process mode"
)
ServingCommand
.
start_single_app_with_file
(
configs
)
else
:
...
...
@@ -358,8 +358,10 @@ class ServingCommand(BaseCommand):
print
(
"config_file "
,
config_file
,
"not exists."
)
else
:
if
platform
.
system
()
==
"Windows"
:
print
(
"Warning: Windows cannot use multiprocess working "
"mode, Hub-Serving will switch to single process mode"
)
print
(
"Warning: Windows cannot use multiprocess working "
"mode, PaddleHub Serving will switch to single process mode"
)
self
.
start_single_app_with_args
()
else
:
if
self
.
args
.
use_multiprocess
is
True
:
...
...
@@ -370,34 +372,41 @@ class ServingCommand(BaseCommand):
@
staticmethod
def
show_help
():
str
=
"serving <option>
\n
"
str
+=
"
\t
Manage PaddleHub
-
Serving.
\n
"
str
+=
"
\t
Manage PaddleHub
Serving.
\n
"
str
+=
"sub command:
\n
"
str
+=
"1. start
\n
"
str
+=
"
\t
Start PaddleHub-Serving if specifies this parameter.
\n
"
str
+=
"2. start bert_service
\n
"
str
+=
"
\t
Start Bert Service if specifies this parameter.
\n
"
str
+=
"
\t
Start PaddleHub Serving.
\n
"
str
+=
"2. stop
\n
"
str
+=
"
\t
Stop PaddleHub Serving.
\n
"
str
+=
"3. start bert_service
\n
"
str
+=
"
\t
Start Bert Service.
\n
"
str
+=
"
\n
"
str
+=
"[start] option:
\n
"
str
+=
"--modules/-m [module1==version, module2==version...]
\n
"
str
+=
"
\t
Pre-install modules via th
is
parameter list.
\n
"
str
+=
"
\t
Pre-install modules via th
e
parameter list.
\n
"
str
+=
"--port/-p XXXX
\n
"
str
+=
"
\t
Use port XXXX for serving.
\n
"
str
+=
"--use_gpu
\n
"
str
+=
"
\t
Use gpu for predicting if
specifies this
parameter.
\n
"
str
+=
"
\t
Use gpu for predicting if
you specify the
parameter.
\n
"
str
+=
"--use_multiprocess
\n
"
str
+=
"
\t
Choose multoprocess mode, cannot be use on Windows.
\n
"
str
+=
"--config/-c file_path
\n
"
str
+=
"
\t
Use configs in file to starting paddlehub serving. "
str
+=
"Other parameter will be ignored if specifies this parameter.
\n
"
str
+=
"
\t
Use configs in file to start PaddleHub Serving. "
str
+=
"Other parameters will be ignored if you specify the parameter.
\n
"
str
+=
"
\n
"
str
+=
"[stop] option:
\n
"
str
+=
"--port/-p XXXX
\n
"
str
+=
"
\t
Stop PaddleHub Serving on port XXXX safely.
\n
"
str
+=
"
\n
"
str
+=
"[start bert_service] option:
\n
"
str
+=
"--modules/-m
\n
"
str
+=
"
\t
Pre-install modules via th
is
parameter.
\n
"
str
+=
"
\t
Pre-install modules via th
e
parameter.
\n
"
str
+=
"--port/-p XXXX
\n
"
str
+=
"
\t
Use port XXXX for serving.
\n
"
str
+=
"--use_gpu
\n
"
str
+=
"
\t
Use gpu for predicting if specifies th
is
parameter.
\n
"
str
+=
"
\t
Use gpu for predicting if specifies th
e
parameter.
\n
"
str
+=
"--gpu
\n
"
str
+=
"
\t
Specify the
graphics card
to use.
\n
"
str
+=
"
\t
Specify the
GPU devices
to use.
\n
"
print
(
str
)
def
execute
(
self
,
argv
):
...
...
@@ -415,7 +424,7 @@ class ServingCommand(BaseCommand):
ServingCommand
.
show_help
()
elif
self
.
args
.
sub_command
==
"stop"
:
if
self
.
args
.
bert_service
==
"bert_service"
:
print
(
"Please stop
bert_s
ervice by kill process by yourself"
)
print
(
"Please stop
Bert S
ervice by kill process by yourself"
)
elif
self
.
args
.
bert_service
is
None
:
self
.
stop_serving
(
port
=
self
.
args
.
port
)
else
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录