Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
5312cdb7
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看板
提交
5312cdb7
编写于
12月 01, 2021
作者:
F
felixhjh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add process check feed_list and fetch_list feature
上级
5d912c2a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
36 addition
and
10 deletion
+36
-10
python/pipeline/error_catch.py
python/pipeline/error_catch.py
+15
-3
python/pipeline/operator.py
python/pipeline/operator.py
+21
-7
未找到文件。
python/pipeline/error_catch.py
浏览文件 @
5312cdb7
...
...
@@ -157,13 +157,13 @@ def ParamChecker(function):
# if there are invalid arguments, raise the error.
if
len
(
invalid_argument_list
)
>
0
:
raise
CustomException
(
CustomExceptionCode
.
INPUT_PARAMS_ERROR
,
"invalid arg list: {}"
.
format
(
invalid_argument_list
))
raise
CustomException
(
CustomExceptionCode
.
INPUT_PARAMS_ERROR
,
"invalid arg list: {}"
.
format
(
invalid_argument_list
)
,
True
)
# check the result.
result
=
function
(
*
args
,
**
kwargs
)
checker
=
inspect
.
signature
(
function
).
return_annotation
if
not
check
(
'return'
,
result
,
checker
,
function
):
raise
CustomException
(
CustomExceptionCode
.
INPUT_PARAMS_ERROR
,
"invalid return type"
)
raise
CustomException
(
CustomExceptionCode
.
INPUT_PARAMS_ERROR
,
"invalid return type"
,
True
)
# return the result.
return
result
...
...
@@ -211,9 +211,21 @@ class ParamVerify(object):
if
len
(
feed_dict
.
keys
())
!=
len
(
feed_list
):
return
False
for
key
in
feed_list
:
if
key
in
feed_dict
.
keys
():
if
key
not
in
feed_dict
.
keys
():
return
False
return
True
@
staticmethod
def
check_fetch_list
(
fetch_list
,
right_fetch_list
):
if
not
isinstance
(
fetch_list
,
list
):
return
False
# read model config, try catch and
if
len
(
fetch_list
)
!=
len
(
right_fetch_list
):
return
False
for
key
in
fetch_list
:
if
key
not
in
right_fetch_list
:
return
False
return
True
ErrorCatch
=
ErrorCatch
()
python/pipeline/operator.py
浏览文件 @
5312cdb7
...
...
@@ -34,7 +34,9 @@ elif sys.version_info.major == 3:
else
:
raise
Exception
(
"Error Python version"
)
from
.error_catch
import
ErrorCatch
,
CustomException
,
CustomExceptionCode
from
.error_catch
import
ErrorCatch
,
CustomException
,
CustomExceptionCode
,
ParamChecker
,
ParamVerify
check_feed_dict
=
ParamVerify
.
check_feed_dict
check_fetch_list
=
ParamVerify
.
check_fetch_list
from
.proto
import
pipeline_service_pb2
from
.channel
import
(
ThreadChannel
,
ProcessChannel
,
ChannelData
,
ChannelDataType
,
ChannelStopError
,
ChannelTimeoutError
)
...
...
@@ -560,7 +562,7 @@ class Op(object):
(
_
,
input_dict
),
=
input_dicts
.
items
()
return
input_dict
,
False
,
None
,
""
def
process
(
self
,
feed_batch
,
typical_logid
=
0
):
"""
In process stage, send requests to the inference server or predict locally.
...
...
@@ -577,7 +579,19 @@ class Op(object):
call_result
=
None
err_code
=
ChannelDataErrcode
.
OK
.
value
err_info
=
""
@
ErrorCatch
@
ParamChecker
def
feed_fetch_list_check_helper
(
feed_batch
:
lambda
feed_batch
:
check_feed_dict
(
feed_batch
[
0
],
self
.
right_feed_names
),
fetch_list
:
lambda
fetch_list
:
check_fetch_list
(
fetch_list
,
self
.
right_fetch_names
),
log_id
):
return
None
_
,
resp
=
feed_fetch_list_check_helper
(
feed_batch
,
self
.
_fetch_names
,
log_id
=
typical_logid
)
if
resp
.
err_no
!=
CustomExceptionCode
.
OK
.
value
:
err_code
=
resp
.
err_no
err_info
=
resp
.
err_msg
call_result
=
None
return
call_result
,
err_code
,
err_info
if
self
.
client_type
==
"local_predictor"
:
err
,
err_info
=
ChannelData
.
check_batch_npdata
(
feed_batch
)
if
err
!=
0
:
...
...
@@ -1030,12 +1044,13 @@ class Op(object):
# 2 kinds of errors
if
error_code
!=
ChannelDataErrcode
.
OK
.
value
or
midped_batch
is
None
:
error_info
=
"(log_id={}) {} failed to predict. Please check the input dict and checkout PipelineServingLogs/pipeline.log for more details."
.
format
(
typical_logid
,
self
.
name
)
error_info
=
"[{}] failed to predict. {}. Please check the input dict and checkout PipelineServingLogs/pipeline.log for more details."
.
format
(
self
.
name
,
error_info
)
_LOGGER
.
error
(
error_info
)
for
data_id
in
data_ids
:
err_channeldata_dict
[
data_id
]
=
ChannelData
(
error_code
=
ChannelDataErrcode
.
CLIENT_ERROR
.
valu
e
,
error_code
=
error_cod
e
,
error_info
=
error_info
,
data_id
=
data_id
,
log_id
=
logid_dict
.
get
(
data_id
))
...
...
@@ -1354,7 +1369,6 @@ class Op(object):
_LOGGER
.
debug
(
"op:{} parse_end:{}"
.
format
(
op_info_prefix
,
time
.
time
()))
# print
front_cost
=
int
(
round
(
_time
()
*
1000000
))
-
start
for
data_id
,
parsed_data
in
parsed_data_dict
.
items
():
_LOGGER
.
debug
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录