Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
21348b99
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看板
提交
21348b99
编写于
5月 28, 2020
作者:
B
barrierye
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
bug fix
上级
eb443288
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
21 addition
and
8 deletion
+21
-8
python/examples/fit_a_line/test_py_client.py
python/examples/fit_a_line/test_py_client.py
+2
-2
python/examples/fit_a_line/test_py_server.py
python/examples/fit_a_line/test_py_server.py
+10
-4
python/paddle_serving_server/pyserver.py
python/paddle_serving_server/pyserver.py
+9
-2
未找到文件。
python/examples/fit_a_line/test_py_client.py
浏览文件 @
21348b99
...
@@ -29,11 +29,11 @@ x = np.array(
...
@@ -29,11 +29,11 @@ x = np.array(
lp
=
LineProfiler
()
lp
=
LineProfiler
()
lp_wrapper
=
lp
(
client
.
predict
)
lp_wrapper
=
lp
(
client
.
predict
)
for
i
in
range
(
3
):
for
i
in
range
(
1
):
fetch_map
=
lp_wrapper
(
fetch_map
=
lp_wrapper
(
feed
=
{
"x"
:
x
},
fetch_with_type
=
{
"combine_op_output"
:
"float"
})
feed
=
{
"x"
:
x
},
fetch_with_type
=
{
"combine_op_output"
:
"float"
})
# fetch_map = client.predict(
# fetch_map = client.predict(
# feed={"x": x}, fetch_with_type={"combine_op_output": "float"})
# feed={"x": x}, fetch_with_type={"combine_op_output": "float"})
print
(
fetch_map
)
print
(
fetch_map
)
lp
.
print_stats
()
#
lp.print_stats()
python/examples/fit_a_line/test_py_server.py
浏览文件 @
21348b99
...
@@ -72,7 +72,9 @@ cnn_op = UciOp(
...
@@ -72,7 +72,9 @@ cnn_op = UciOp(
client_config
=
"uci_housing_client/serving_client_conf.prototxt"
,
client_config
=
"uci_housing_client/serving_client_conf.prototxt"
,
server_name
=
"127.0.0.1:9393"
,
server_name
=
"127.0.0.1:9393"
,
fetch_names
=
[
"price"
],
fetch_names
=
[
"price"
],
concurrency
=
1
)
concurrency
=
1
,
timeout
=
0.01
,
retry
=
2
)
bow_op
=
UciOp
(
bow_op
=
UciOp
(
name
=
"bow"
,
name
=
"bow"
,
...
@@ -86,7 +88,9 @@ bow_op = UciOp(
...
@@ -86,7 +88,9 @@ bow_op = UciOp(
client_config
=
"uci_housing_client/serving_client_conf.prototxt"
,
client_config
=
"uci_housing_client/serving_client_conf.prototxt"
,
server_name
=
"127.0.0.1:9393"
,
server_name
=
"127.0.0.1:9393"
,
fetch_names
=
[
"price"
],
fetch_names
=
[
"price"
],
concurrency
=
1
)
concurrency
=
1
,
timeout
=-
1
,
retry
=
1
)
combine_op
=
CombineOp
(
combine_op
=
CombineOp
(
name
=
"combine"
,
name
=
"combine"
,
...
@@ -94,12 +98,14 @@ combine_op = CombineOp(
...
@@ -94,12 +98,14 @@ combine_op = CombineOp(
in_dtype
=
'float'
,
in_dtype
=
'float'
,
outputs
=
[
out_channel
],
outputs
=
[
out_channel
],
out_dtype
=
'float'
,
out_dtype
=
'float'
,
concurrency
=
1
)
concurrency
=
1
,
timeout
=-
1
,
retry
=
1
)
logging
.
info
(
read_channel
.
debug
())
logging
.
info
(
read_channel
.
debug
())
logging
.
info
(
combine_channel
.
debug
())
logging
.
info
(
combine_channel
.
debug
())
logging
.
info
(
out_channel
.
debug
())
logging
.
info
(
out_channel
.
debug
())
pyserver
=
PyServer
(
profile
=
False
)
pyserver
=
PyServer
(
profile
=
False
,
retry
=
1
)
pyserver
.
add_channel
(
read_channel
)
pyserver
.
add_channel
(
read_channel
)
pyserver
.
add_channel
(
combine_channel
)
pyserver
.
add_channel
(
combine_channel
)
pyserver
.
add_channel
(
out_channel
)
pyserver
.
add_channel
(
out_channel
)
...
...
python/paddle_serving_server/pyserver.py
浏览文件 @
21348b99
...
@@ -42,12 +42,16 @@ class _TimeProfiler(object):
...
@@ -42,12 +42,16 @@ class _TimeProfiler(object):
self
.
_enable
=
enable
self
.
_enable
=
enable
def
record
(
self
,
name_with_tag
):
def
record
(
self
,
name_with_tag
):
if
self
.
_enable
is
False
:
return
name_with_tag
=
name_with_tag
.
split
(
"_"
)
name_with_tag
=
name_with_tag
.
split
(
"_"
)
tag
=
name_with_tag
[
-
1
]
tag
=
name_with_tag
[
-
1
]
name
=
'_'
.
join
(
name_with_tag
[:
-
1
])
name
=
'_'
.
join
(
name_with_tag
[:
-
1
])
self
.
_time_record
.
put
((
name
,
tag
,
int
(
round
(
time
.
time
()
*
1000000
))))
self
.
_time_record
.
put
((
name
,
tag
,
int
(
round
(
time
.
time
()
*
1000000
))))
def
print_profile
(
self
):
def
print_profile
(
self
):
if
self
.
_enable
is
False
:
return
sys
.
stderr
.
write
(
self
.
_print_head
)
sys
.
stderr
.
write
(
self
.
_print_head
)
tmp
=
{}
tmp
=
{}
while
not
self
.
_time_record
.
empty
():
while
not
self
.
_time_record
.
empty
():
...
@@ -392,10 +396,12 @@ class Op(object):
...
@@ -392,10 +396,12 @@ class Op(object):
for
i
in
range
(
self
.
_retry
):
for
i
in
range
(
self
.
_retry
):
_profiler
.
record
(
"{}{}-midp_0"
.
format
(
self
.
_name
,
_profiler
.
record
(
"{}{}-midp_0"
.
format
(
self
.
_name
,
concurrency_idx
))
concurrency_idx
))
if
self
.
_time
>
0
:
if
self
.
_time
out
>
0
:
try
:
try
:
middata
=
func_timeout
.
func_timeout
(
middata
=
func_timeout
.
func_timeout
(
self
.
_time
,
self
.
midprocess
,
args
=
(
data
,
))
self
.
_timeout
,
self
.
midprocess
,
args
=
(
data
,
))
except
func_timeout
.
FunctionTimedOut
:
except
func_timeout
.
FunctionTimedOut
:
logging
.
error
(
"error: timeout"
)
logging
.
error
(
"error: timeout"
)
error_info
=
"{}({}): timeout"
.
format
(
error_info
=
"{}({}): timeout"
.
format
(
...
@@ -520,6 +526,7 @@ class GeneralPythonService(
...
@@ -520,6 +526,7 @@ class GeneralPythonService(
data
=
python_service_channel_pb2
.
ChannelData
()
data
=
python_service_channel_pb2
.
ChannelData
()
data_id
=
self
.
_get_next_id
()
data_id
=
self
.
_get_next_id
()
data
.
id
=
data_id
data
.
id
=
data_id
data
.
is_error
=
0
for
idx
,
name
in
enumerate
(
request
.
feed_var_names
):
for
idx
,
name
in
enumerate
(
request
.
feed_var_names
):
logging
.
debug
(
logging
.
debug
(
self
.
_log
(
'name: {}'
.
format
(
request
.
feed_var_names
[
idx
])))
self
.
_log
(
'name: {}'
.
format
(
request
.
feed_var_names
[
idx
])))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录