Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
b92e2b77
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看板
提交
b92e2b77
编写于
7月 17, 2020
作者:
B
barrierye
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change `build DAG each request` to `build DAG each worker`
上级
b4029edb
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
12 addition
and
27 deletion
+12
-27
python/examples/pipeline/imdb_model_ensemble/config.yml
python/examples/pipeline/imdb_model_ensemble/config.yml
+1
-1
python/pipeline/pipeline_server.py
python/pipeline/pipeline_server.py
+11
-26
未找到文件。
python/examples/pipeline/imdb_model_ensemble/config.yml
浏览文件 @
b92e2b77
port
:
18080
worker_num
:
1
build_dag_each_
request
:
false
build_dag_each_
worker
:
false
dag
:
is_thread_op
:
true
client_type
:
brpc
...
...
python/pipeline/pipeline_server.py
浏览文件 @
b92e2b77
...
...
@@ -29,11 +29,11 @@ _LOGGER = logging.getLogger()
class
PipelineService
(
pipeline_service_pb2_grpc
.
PipelineServiceServicer
):
def
__init__
(
self
,
response_op
,
dag_config
):
def
__init__
(
self
,
response_op
,
dag_config
,
show_info
):
super
(
PipelineService
,
self
).
__init__
()
# init dag executor
self
.
_dag_executor
=
DAGExecutor
(
response_op
,
dag_config
,
show_info
=
True
)
response_op
,
dag_config
,
show_info
=
show_info
)
self
.
_dag_executor
.
start
()
def
inference
(
self
,
request
,
context
):
...
...
@@ -44,22 +44,6 @@ class PipelineService(pipeline_service_pb2_grpc.PipelineServiceServicer):
self
.
_dag_executor
.
stop
()
class
ProcessPipelineService
(
pipeline_service_pb2_grpc
.
PipelineServiceServicer
):
def
__init__
(
self
,
response_op
,
dag_config
):
super
(
ProcessPipelineService
,
self
).
__init__
()
self
.
_response_op
=
response_op
self
.
_dag_config
=
dag_config
def
inference
(
self
,
request
,
context
):
# init dag executor
dag_executor
=
DAGExecutor
(
self
.
_response_op
,
self
.
_dag_config
,
show_info
=
False
)
dag_executor
.
start
()
resp
=
dag_executor
.
call
(
request
)
dag_executor
.
stop
()
return
resp
@
contextlib
.
contextmanager
def
_reserve_port
(
port
):
"""Find and reserve a port for all subprocesses to use."""
...
...
@@ -103,14 +87,14 @@ class PipelineServer(object):
if
not
self
.
_port_is_available
(
self
.
_port
):
raise
SystemExit
(
"Prot {} is already used"
.
format
(
self
.
_port
))
self
.
_worker_num
=
yml_config
.
get
(
'worker_num'
,
1
)
self
.
_build_dag_each_
request
=
yml_config
.
get
(
'build_dag_each_request
'
,
False
)
self
.
_build_dag_each_
worker
=
yml_config
.
get
(
'build_dag_each_worker
'
,
False
)
_LOGGER
.
info
(
"============= PIPELINE SERVER ============="
)
_LOGGER
.
info
(
"port: {}"
.
format
(
self
.
_port
))
_LOGGER
.
info
(
"worker_num: {}"
.
format
(
self
.
_worker_num
))
servicer_info
=
"build_dag_each_
request
: {}"
.
format
(
self
.
_build_dag_each_
request
)
if
self
.
_build_dag_each_
request
is
True
:
servicer_info
=
"build_dag_each_
worker
: {}"
.
format
(
self
.
_build_dag_each_
worker
)
if
self
.
_build_dag_each_
worker
is
True
:
servicer_info
+=
" (Make sure that install grpcio whl with --no-binary flag)"
_LOGGER
.
info
(
servicer_info
)
_LOGGER
.
info
(
"-------------------------------------------"
)
...
...
@@ -118,7 +102,7 @@ class PipelineServer(object):
self
.
_dag_config
=
yml_config
.
get
(
"dag"
,
{})
def
run_server
(
self
):
if
self
.
_build_dag_each_
request
:
if
self
.
_build_dag_each_
worker
:
with
_reserve_port
(
self
.
_port
)
as
port
:
bind_address
=
'localhost:{}'
.
format
(
port
)
workers
=
[]
...
...
@@ -136,7 +120,8 @@ class PipelineServer(object):
server
=
grpc
.
server
(
futures
.
ThreadPoolExecutor
(
max_workers
=
self
.
_worker_num
))
pipeline_service_pb2_grpc
.
add_PipelineServiceServicer_to_server
(
PipelineService
(
self
.
_response_op
,
self
.
_dag_config
),
server
)
PipelineService
(
self
.
_response_op
,
self
.
_dag_config
,
True
),
server
)
server
.
add_insecure_port
(
'[::]:{}'
.
format
(
self
.
_port
))
server
.
start
()
server
.
wait_for_termination
()
...
...
@@ -147,7 +132,7 @@ class PipelineServer(object):
futures
.
ThreadPoolExecutor
(
max_workers
=
1
,
),
options
=
options
)
pipeline_service_pb2_grpc
.
add_PipelineServiceServicer_to_server
(
P
rocessPipelineService
(
response_op
,
dag_config
),
server
)
P
ipelineService
(
response_op
,
dag_config
,
False
),
server
)
server
.
add_insecure_port
(
bind_address
)
server
.
start
()
server
.
wait_for_termination
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录