Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
b2df4cc7
S
Serving
项目概览
PaddlePaddle
/
Serving
大约 1 年 前同步成功
通知
186
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看板
提交
b2df4cc7
编写于
11月 25, 2021
作者:
B
bjjwwang
浏览文件
操作
浏览文件
下载
差异文件
fix conflict
上级
383cc4c9
5e3bdff5
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
93 addition
and
25 deletion
+93
-25
doc/Quick_Start_CN.md
doc/Quick_Start_CN.md
+10
-0
doc/Quick_Start_EN.md
doc/Quick_Start_EN.md
+10
-0
doc/Serving_Configure_CN.md
doc/Serving_Configure_CN.md
+19
-1
doc/Serving_Configure_EN.md
doc/Serving_Configure_EN.md
+3
-3
doc/images/wechat_group_1.jpeg
doc/images/wechat_group_1.jpeg
+0
-0
python/pipeline/dag.py
python/pipeline/dag.py
+4
-2
python/pipeline/error_catch.py
python/pipeline/error_catch.py
+37
-14
python/pipeline/operator.py
python/pipeline/operator.py
+9
-5
python/pipeline/pipeline_server.py
python/pipeline/pipeline_server.py
+1
-0
未找到文件。
doc/Quick_Start_CN.md
浏览文件 @
b2df4cc7
...
@@ -123,3 +123,13 @@ python3 pipeline_rpc_client.py
...
@@ -123,3 +123,13 @@ python3 pipeline_rpc_client.py
```
```
{'err_no': 0, 'err_msg': '', 'key': ['res'], 'value': ["['土地整治与土壤修复研究中心', '华南农业大学1素图']"]}
{'err_no': 0, 'err_msg': '', 'key': ['res'], 'value': ["['土地整治与土壤修复研究中心', '华南农业大学1素图']"]}
```
```
<h3
align=
"center"
>
关闭Serving/Pipeline服务
</h3>
**方式一**
:Ctrl+C关停服务
**方式二**
:在启动Serving/Pipeline服务路径或者环境变量SERVING_HOME路径下(该路径下存在文件ProcessInfo.json)
```
python3 -m paddle_serving_server.serve stop
```
doc/Quick_Start_EN.md
浏览文件 @
b2df4cc7
...
@@ -94,3 +94,13 @@ output
...
@@ -94,3 +94,13 @@ output
```
```
{'err_no': 0, 'err_msg': '', 'key': ['res'], 'value': ["['土地整治与土壤修复研究中心', '华南农业大学1素图']"]}
{'err_no': 0, 'err_msg': '', 'key': ['res'], 'value': ["['土地整治与土壤修复研究中心', '华南农业大学1素图']"]}
```
```
<h3
align=
"center"
>
Stop Serving/Pipeline service
</h3>
**Method one**
:Ctrl+C to quit
**Method Two**
:In the path where starting the Serving/Pipeline service or the path which environment variable SERVING_HOME set (the file named ProcessInfo.json exists in this path)
```
python3 -m paddle_serving_server.serve stop
```
doc/Serving_Configure_CN.md
浏览文件 @
b2df4cc7
...
@@ -59,7 +59,7 @@ fetch_var {
...
@@ -59,7 +59,7 @@ fetch_var {
## C++ Serving
## C++ Serving
### 1.快速启动
### 1.快速启动
与关闭
可以通过配置模型及端口号快速启动服务,启动命令如下:
可以通过配置模型及端口号快速启动服务,启动命令如下:
...
@@ -107,6 +107,11 @@ python3 -m paddle_serving_server.serve --model serving_model --thread 10 --port
...
@@ -107,6 +107,11 @@ python3 -m paddle_serving_server.serve --model serving_model --thread 10 --port
```
BASH
```
BASH
python3 -m paddle_serving_server.serve --model serving_model_1 serving_model_2 --thread 10 --port 9292
python3 -m paddle_serving_server.serve --model serving_model_1 serving_model_2 --thread 10 --port 9292
```
```
#### 当您想要关闭Serving服务时(在Serving启动目录或环境变量SERVING_HOME路径下,执行以下命令).
```
BASH
python3 -m paddle_serving_server.serve stop
```
stop参数发送SIGINT至C++ Serving,若改成kill则发送SIGKILL信号至C++ Serving
### 2.自定义配置启动
### 2.自定义配置启动
...
@@ -312,7 +317,20 @@ fetch_var {
...
@@ -312,7 +317,20 @@ fetch_var {
```
```
## Python Pipeline
## Python Pipeline
### 快速启动与关闭
Python Pipeline启动命令如下:
```
BASH
python3 web_service.py
```
当您想要关闭Serving服务时(在Pipeline启动目录下或环境变量SERVING_HOME路径下,执行以下命令):
```
BASH
python3 -m paddle_serving_server.serve stop
```
stop参数发送SIGINT至Pipeline Serving,若改成kill则发送SIGKILL信号至Pipeline Serving
### 配置文件
Python Pipeline提供了用户友好的多模型组合服务编程框架,适用于多模型组合应用的场景。
Python Pipeline提供了用户友好的多模型组合服务编程框架,适用于多模型组合应用的场景。
其配置文件为YAML格式,一般默认为config.yaml。示例如下:
其配置文件为YAML格式,一般默认为config.yaml。示例如下:
```
YAML
```
YAML
...
...
doc/Serving_Configure_EN.md
浏览文件 @
b2df4cc7
...
@@ -107,7 +107,7 @@ python3 -m paddle_serving_server.serve --model serving_model --thread 10 --port
...
@@ -107,7 +107,7 @@ python3 -m paddle_serving_server.serve --model serving_model --thread 10 --port
```
BASH
```
BASH
python3 -m paddle_serving_server.serve --model serving_model_1 serving_model_2 --thread 10 --port 9292
python3 -m paddle_serving_server.serve --model serving_model_1 serving_model_2 --thread 10 --port 9292
```
```
#### Stop Serving.
#### Stop Serving
(execute the following command in the directory where start serving or the path which environment variable SERVING_HOME set)
.
```
BASH
```
BASH
python3 -m paddle_serving_server.serve stop
python3 -m paddle_serving_server.serve stop
```
```
...
@@ -325,9 +325,9 @@ fetch_var {
...
@@ -325,9 +325,9 @@ fetch_var {
Example starting Pipeline Serving:
Example starting Pipeline Serving:
```
BASH
```
BASH
python3
-m paddle_serving_server.serve --model serving_model --port 9393
python3
web_service.py
```
```
### Stop Serving.
### Stop Serving
(execute the following command in the directory where start Pipeline serving or the path which environment variable SERVING_HOME set)
.
```
BASH
```
BASH
python3 -m paddle_serving_server.serve stop
python3 -m paddle_serving_server.serve stop
```
```
...
...
doc/images/wechat_group_1.jpeg
查看替换文件 @
383cc4c9
浏览文件 @
b2df4cc7
91.8 KB
|
W:
|
H:
51.1 KB
|
W:
|
H:
2-up
Swipe
Onion skin
python/pipeline/dag.py
浏览文件 @
b2df4cc7
...
@@ -29,8 +29,9 @@ import json
...
@@ -29,8 +29,9 @@ import json
from
.error_catch
import
ErrorCatch
,
CustomException
,
CustomExceptionCode
,
ParamChecker
,
ParamVerify
from
.error_catch
import
ErrorCatch
,
CustomException
,
CustomExceptionCode
,
ParamChecker
,
ParamVerify
from
.operator
import
Op
,
RequestOp
,
ResponseOp
,
VirtualOp
from
.operator
import
Op
,
RequestOp
,
ResponseOp
,
VirtualOp
from
.channel
import
(
ThreadChannel
,
ProcessChannel
,
ChannelData
,
from
.channel
import
(
ThreadChannel
,
ProcessChannel
,
ChannelData
,
ChannelDataErrcode
,
ChannelDataType
,
ChannelStopError
,
ChannelDataType
,
ChannelStopError
)
ProductErrCode
)
from
.error_catch
import
ProductErrCode
from
.error_catch
import
CustomExceptionCode
as
ChannelDataErrcode
from
.profiler
import
TimeProfiler
,
PerformanceTracer
from
.profiler
import
TimeProfiler
,
PerformanceTracer
from
.util
import
NameGenerator
,
ThreadIdGenerator
,
PipelineProcSyncManager
from
.util
import
NameGenerator
,
ThreadIdGenerator
,
PipelineProcSyncManager
from
.proto
import
pipeline_service_pb2
from
.proto
import
pipeline_service_pb2
...
@@ -508,6 +509,7 @@ class DAG(object):
...
@@ -508,6 +509,7 @@ class DAG(object):
init_helper
(
self
,
request_name
,
response_op
,
use_profile
,
is_thread_op
,
init_helper
(
self
,
request_name
,
response_op
,
use_profile
,
is_thread_op
,
channel_size
,
build_dag_each_worker
,
tracer
,
channel_size
,
build_dag_each_worker
,
tracer
,
channel_recv_frist_arrive
)
channel_recv_frist_arrive
)
print
(
"[DAG] Succ init"
)
_LOGGER
.
info
(
"[DAG] Succ init"
)
_LOGGER
.
info
(
"[DAG] Succ init"
)
@
staticmethod
@
staticmethod
...
...
python/pipeline/error_catch.py
浏览文件 @
b2df4cc7
...
@@ -48,13 +48,24 @@ class CustomExceptionCode(enum.Enum):
...
@@ -48,13 +48,24 @@ class CustomExceptionCode(enum.Enum):
class
ProductErrCode
(
enum
.
Enum
):
class
ProductErrCode
(
enum
.
Enum
):
"""
"""
ProductErrCode is a base class for recording business error code.
ProductErrCode is to record business error codes.
product developers inherit this class and extend more error codes.
the ProductErrCode number ranges from 51 to 99
product developers can directly add error code into this class.
"""
"""
pass
pass
class
CustomException
(
Exception
):
class
CustomException
(
Exception
):
"""
An self-defined exception class
Usage : raise CustomException(CustomExceptionCode.exceptionCode, errorMsg, isSendToUser=False)
Args :
exceptionCode : CustomExceptionCode or ProductErrCode
errorMsg : string message you want to describe the error
isSendToUser : whether send to user or just record in errorlog
Return : An string of error_info
"""
def
__init__
(
self
,
exceptionCode
,
errorMsg
,
isSendToUser
=
False
):
def
__init__
(
self
,
exceptionCode
,
errorMsg
,
isSendToUser
=
False
):
super
().
__init__
(
self
)
super
().
__init__
(
self
)
self
.
error_info
=
"
\n\t
exception_code: {}
\n
"
\
self
.
error_info
=
"
\n\t
exception_code: {}
\n
"
\
...
@@ -69,12 +80,15 @@ class CustomException(Exception):
...
@@ -69,12 +80,15 @@ class CustomException(Exception):
class
ErrorCatch
():
class
ErrorCatch
():
def
__init__
(
self
):
"""
self
.
_id_generator
=
ThreadIdGenerator
(
An decorator class to catch error for method or function.
max_id
=
1000000000000000000
,
base_counter
=
0
,
step
=
1
)
Usage : @ErrorCatch
Args : None
Returns: tuple(res, response)
res is the original funciton return
response includes erro_no and erro_msg
"""
def
__call__
(
self
,
func
):
def
__call__
(
self
,
func
):
if
inspect
.
isfunction
(
func
)
or
inspect
.
ismethod
(
func
):
if
inspect
.
isfunction
(
func
)
or
inspect
.
ismethod
(
func
):
@
functools
.
wraps
(
func
)
@
functools
.
wraps
(
func
)
...
@@ -82,27 +96,36 @@ class ErrorCatch():
...
@@ -82,27 +96,36 @@ class ErrorCatch():
try
:
try
:
res
=
func
(
*
args
,
**
kw
)
res
=
func
(
*
args
,
**
kw
)
except
CustomException
as
e
:
except
CustomException
as
e
:
log_id
=
self
.
_id_generator
.
next
()
if
"log_id"
in
kw
.
keys
():
log_id
=
kw
[
"log_id"
]
elif
"logid_dict"
in
kw
.
keys
()
and
"data_id"
in
kw
.
keys
():
log_id
=
kw
[
"logid_dict"
].
get
(
kw
[
"data_id"
])
else
:
log_id
=
0
resp
=
pipeline_service_pb2
.
Response
()
resp
=
pipeline_service_pb2
.
Response
()
_LOGGER
.
error
(
"
\n
Log_id: {}
\n
{}Classname: {}
\n
FunctionName:
{}"
.
format
(
log_id
,
traceback
.
format_exc
(),
func
.
__qualname__
,
func
.
__name__
))
_LOGGER
.
error
(
"
\n
Log_id: {}
\n
{}Classname: {}
\n
FunctionName:
{}
\n
Args: {}"
.
format
(
log_id
,
traceback
.
format_exc
(),
func
.
__qualname__
,
func
.
__name__
,
args
))
split_list
=
re
.
split
(
"
\n
|
\t
|:"
,
str
(
e
))
split_list
=
re
.
split
(
"
\n
|
\t
|:"
,
str
(
e
))
resp
.
err_no
=
int
(
split_list
[
3
])
resp
.
err_no
=
int
(
split_list
[
3
])
resp
.
err_msg
=
"Log_id: {}
ErrNo: {} Error_msg: {} ClassName: {} FunctionName: {}"
.
format
(
log_id
,
resp
.
err_no
,
split_list
[
9
],
func
.
__qualname__
,
func
.
__name__
)
resp
.
err_msg
=
"Log_id: {}
Raise_msg: {} ClassName: {} FunctionName: {}"
.
format
(
log_id
,
split_list
[
9
],
func
.
__qualname__
,
func
.
__name__
)
is_send_to_user
=
split_list
[
-
1
].
replace
(
" "
,
""
)
is_send_to_user
=
split_list
[
-
1
].
replace
(
" "
,
""
)
if
is_send_to_user
==
"True"
:
if
is_send_to_user
==
"True"
:
return
(
None
,
resp
)
return
(
None
,
resp
)
else
:
else
:
print
(
"Erro_Num: {} {}"
.
format
(
resp
.
err_no
,
resp
.
err_msg
))
print
(
"Erro_Num: {} {}"
.
format
(
resp
.
err_no
,
resp
.
err_msg
))
print
(
"Init error occurs. For detailed information
, Please look up log
by log_id."
)
print
(
"Init error occurs. For detailed information
. Please look up pipeline.log.wf in PipelineServingLogs
by log_id."
)
kill_stop_process_by_pid
(
"kill"
,
os
.
getpgid
(
os
.
getpid
()))
kill_stop_process_by_pid
(
"kill"
,
os
.
getpgid
(
os
.
getpid
()))
except
Exception
as
e
:
except
Exception
as
e
:
log_id
=
self
.
_id_generator
.
next
()
if
"log_id"
in
kw
.
keys
():
log_id
=
kw
[
"log_id"
]
elif
"logid_dict"
in
kw
.
keys
()
and
"data_id"
in
kw
.
keys
():
log_id
=
kw
[
"logid_dict"
].
get
(
kw
[
"data_id"
])
else
:
log_id
=
0
resp
=
pipeline_service_pb2
.
Response
()
resp
=
pipeline_service_pb2
.
Response
()
_LOGGER
.
error
(
"
\n
Log_id: {}
\n
{}Classname: {}
\n
FunctionName: {}"
.
format
(
log_id
,
traceback
.
format_exc
(),
func
.
__qualname__
,
func
.
__name__
))
_LOGGER
.
error
(
"
\n
Log_id: {}
\n
{}Classname: {}
\n
FunctionName: {}"
.
format
(
log_id
,
traceback
.
format_exc
(),
func
.
__qualname__
,
func
.
__name__
))
resp
.
err_no
=
CustomExceptionCode
.
UNKNOW
.
value
resp
.
err_no
=
CustomExceptionCode
.
UNKNOW
.
value
resp
.
err_msg
=
"Log_id: {}
ErrNo: {} Error_msg: {} ClassName: {} FunctionName: {}"
.
format
(
log_id
,
resp
.
err_no
,
str
(
e
).
replace
(
"
\'
"
,
""
),
func
.
__qualname__
,
func
.
__name__
)
resp
.
err_msg
=
"Log_id: {}
Raise_msg: {} ClassName: {} FunctionName: {}"
.
format
(
log_id
,
str
(
e
).
replace
(
"
\'
"
,
""
),
func
.
__qualname__
,
func
.
__name__
)
return
(
None
,
resp
)
return
(
None
,
resp
)
# other exception won't be sent to users.
else
:
else
:
resp
=
pipeline_service_pb2
.
Response
()
resp
=
pipeline_service_pb2
.
Response
()
resp
.
err_no
=
CustomExceptionCode
.
OK
.
value
resp
.
err_no
=
CustomExceptionCode
.
OK
.
value
...
...
python/pipeline/operator.py
浏览文件 @
b2df4cc7
...
@@ -36,9 +36,10 @@ else:
...
@@ -36,9 +36,10 @@ else:
from
.error_catch
import
ErrorCatch
,
CustomException
,
CustomExceptionCode
from
.error_catch
import
ErrorCatch
,
CustomException
,
CustomExceptionCode
from
.proto
import
pipeline_service_pb2
from
.proto
import
pipeline_service_pb2
from
.channel
import
(
ThreadChannel
,
ProcessChannel
,
ChannelDataErrcode
,
from
.channel
import
(
ThreadChannel
,
ProcessChannel
,
ChannelData
,
ChannelData
,
ChannelDataType
,
ChannelStopError
,
ChannelDataType
,
ChannelStopError
,
ChannelTimeoutError
)
ChannelTimeoutError
,
ProductErrCode
)
from
.error_catch
import
ProductErrCode
from
.error_catch
import
CustomExceptionCode
as
ChannelDataErrcode
from
.util
import
NameGenerator
from
.util
import
NameGenerator
from
.profiler
import
UnsafeTimeProfiler
as
TimeProfiler
from
.profiler
import
UnsafeTimeProfiler
as
TimeProfiler
from
.
import
local_service_handler
from
.
import
local_service_handler
...
@@ -828,7 +829,8 @@ class Op(object):
...
@@ -828,7 +829,8 @@ class Op(object):
is_skip_process
=
False
is_skip_process
=
False
prod_errcode
,
prod_errinfo
=
None
,
None
prod_errcode
,
prod_errinfo
=
None
,
None
log_id
=
logid_dict
.
get
(
data_id
)
log_id
=
logid_dict
.
get
(
data_id
)
process_res
,
resp
=
preprocess_help
(
self
,
parsed_data
,
data_id
,
logid_dict
)
process_res
,
resp
=
preprocess_help
(
self
,
parsed_data
,
data_id
=
data_id
,
logid_dict
=
logid_dict
)
if
resp
.
err_no
==
CustomExceptionCode
.
OK
.
value
:
if
resp
.
err_no
==
CustomExceptionCode
.
OK
.
value
:
preped_data
,
is_skip_process
,
prod_errcode
,
prod_errinfo
=
process_res
preped_data
,
is_skip_process
,
prod_errcode
,
prod_errinfo
=
process_res
if
is_skip_process
is
True
:
if
is_skip_process
is
True
:
...
@@ -1117,7 +1119,8 @@ class Op(object):
...
@@ -1117,7 +1119,8 @@ class Op(object):
postped_data
,
err_channeldata
=
None
,
None
postped_data
,
err_channeldata
=
None
,
None
prod_errcode
,
prod_errinfo
=
None
,
None
prod_errcode
,
prod_errinfo
=
None
,
None
post_res
,
resp
=
postprocess_help
(
self
,
parsed_data_dict
,
midped_data
,
data_id
,
logid_dict
)
post_res
,
resp
=
postprocess_help
(
self
,
parsed_data_dict
,
midped_data
,
data_id
=
data_id
,
logid_dict
=
logid_dict
)
if
resp
.
err_no
==
CustomExceptionCode
.
OK
.
value
:
if
resp
.
err_no
==
CustomExceptionCode
.
OK
.
value
:
postped_data
,
prod_errcode
,
prod_errinfo
=
post_res
postped_data
,
prod_errcode
,
prod_errinfo
=
post_res
if
prod_errcode
is
not
None
:
if
prod_errcode
is
not
None
:
...
@@ -1528,6 +1531,7 @@ class Op(object):
...
@@ -1528,6 +1531,7 @@ class Op(object):
self
.
init_op
()
self
.
init_op
()
init_helper
(
self
,
is_thread_op
,
concurrency_idx
)
init_helper
(
self
,
is_thread_op
,
concurrency_idx
)
print
(
"[OP Object] init success"
)
# use a separate TimeProfiler per thread or process
# use a separate TimeProfiler per thread or process
profiler
=
TimeProfiler
()
profiler
=
TimeProfiler
()
profiler
.
enable
(
True
)
profiler
.
enable
(
True
)
...
...
python/pipeline/pipeline_server.py
浏览文件 @
b2df4cc7
...
@@ -55,6 +55,7 @@ class PipelineServicer(pipeline_service_pb2_grpc.PipelineServiceServicer):
...
@@ -55,6 +55,7 @@ class PipelineServicer(pipeline_service_pb2_grpc.PipelineServiceServicer):
init_res
=
init_helper
(
self
,
name
,
response_op
,
dag_conf
,
worker_idx
)
init_res
=
init_helper
(
self
,
name
,
response_op
,
dag_conf
,
worker_idx
)
if
init_res
[
1
].
err_no
!=
CustomExceptionCode
.
OK
.
value
:
if
init_res
[
1
].
err_no
!=
CustomExceptionCode
.
OK
.
value
:
raise
CustomException
(
CustomExceptionCode
.
INIT_ERROR
,
"pipeline server init error"
)
raise
CustomException
(
CustomExceptionCode
.
INIT_ERROR
,
"pipeline server init error"
)
print
(
"[PipelineServicer] succ init"
)
_LOGGER
.
info
(
"[PipelineServicer] succ init"
)
_LOGGER
.
info
(
"[PipelineServicer] succ init"
)
def
inference
(
self
,
request
,
context
):
def
inference
(
self
,
request
,
context
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录