Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
6d74f2a8
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看板
提交
6d74f2a8
编写于
8月 25, 2020
作者:
B
barriery
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update url
上级
23a566bb
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
27 addition
and
13 deletion
+27
-13
python/examples/pipeline/ocr/pipeline_http_client.py
python/examples/pipeline/ocr/pipeline_http_client.py
+1
-1
python/examples/pipeline/simple_web_service/README.md
python/examples/pipeline/simple_web_service/README.md
+1
-1
python/examples/pipeline/simple_web_service/README_CN.md
python/examples/pipeline/simple_web_service/README_CN.md
+1
-1
python/examples/pipeline/simple_web_service/web_service.py
python/examples/pipeline/simple_web_service/web_service.py
+1
-1
python/paddle_serving_server/web_service.py
python/paddle_serving_server/web_service.py
+1
-1
python/paddle_serving_server_gpu/web_service.py
python/paddle_serving_server_gpu/web_service.py
+1
-1
python/pipeline/channel.py
python/pipeline/channel.py
+2
-1
python/pipeline/gateway/proto/gateway.proto
python/pipeline/gateway/proto/gateway.proto
+2
-1
python/pipeline/pipeline_server.py
python/pipeline/pipeline_server.py
+16
-5
python/pipeline/proto/pipeline_service.proto
python/pipeline/proto/pipeline_service.proto
+1
-0
未找到文件。
python/examples/pipeline/ocr/pipeline_http_client.py
浏览文件 @
6d74f2a8
...
@@ -24,7 +24,7 @@ def cv2_to_base64(image):
...
@@ -24,7 +24,7 @@ def cv2_to_base64(image):
return
base64
.
b64encode
(
image
).
decode
(
'utf8'
)
return
base64
.
b64encode
(
image
).
decode
(
'utf8'
)
url
=
"http://127.0.0.1:9999/prediction"
url
=
"http://127.0.0.1:9999/
ocr/
prediction"
test_img_dir
=
"imgs/"
test_img_dir
=
"imgs/"
for
img_file
in
os
.
listdir
(
test_img_dir
):
for
img_file
in
os
.
listdir
(
test_img_dir
):
with
open
(
os
.
path
.
join
(
test_img_dir
,
img_file
),
'rb'
)
as
file
:
with
open
(
os
.
path
.
join
(
test_img_dir
,
img_file
),
'rb'
)
as
file
:
...
...
python/examples/pipeline/simple_web_service/README.md
浏览文件 @
6d74f2a8
...
@@ -15,5 +15,5 @@ python web_service.py &>log.txt &
...
@@ -15,5 +15,5 @@ python web_service.py &>log.txt &
## Http test
## Http test
```
```
curl -X POST -k http://localhost:18080/prediction -d '{"key": ["x"], "value": ["0.0137, -0.1136, 0.2553, -0.0692, 0.0582, -0.0727, -0.1583, -0.0584, 0.6283, 0.4919, 0.1856, 0.0795, -0.0332"]}'
curl -X POST -k http://localhost:18080/
uci/
prediction -d '{"key": ["x"], "value": ["0.0137, -0.1136, 0.2553, -0.0692, 0.0582, -0.0727, -0.1583, -0.0584, 0.6283, 0.4919, 0.1856, 0.0795, -0.0332"]}'
```
```
python/examples/pipeline/simple_web_service/README_CN.md
浏览文件 @
6d74f2a8
...
@@ -15,5 +15,5 @@ python web_service.py &>log.txt &
...
@@ -15,5 +15,5 @@ python web_service.py &>log.txt &
## 测试
## 测试
```
```
curl -X POST -k http://localhost:18080/prediction -d '{"key": ["x"], "value": ["0.0137, -0.1136, 0.2553, -0.0692, 0.0582, -0.0727, -0.1583, -0.0584, 0.6283, 0.4919, 0.1856, 0.0795, -0.0332"]}'
curl -X POST -k http://localhost:18080/
uci/
prediction -d '{"key": ["x"], "value": ["0.0137, -0.1136, 0.2553, -0.0692, 0.0582, -0.0727, -0.1583, -0.0584, 0.6283, 0.4919, 0.1856, 0.0795, -0.0332"]}'
```
```
python/examples/pipeline/simple_web_service/web_service.py
浏览文件 @
6d74f2a8
...
@@ -35,7 +35,7 @@ class UciOp(Op):
...
@@ -35,7 +35,7 @@ class UciOp(Op):
return
input_dict
return
input_dict
def
postprocess
(
self
,
input_dicts
,
fetch_dict
):
def
postprocess
(
self
,
input_dicts
,
fetch_dict
):
_LOGGER
.
info
(
fetch_dict
)
#
_LOGGER.info(fetch_dict)
fetch_dict
[
"price"
]
=
str
(
fetch_dict
[
"price"
][
0
][
0
])
fetch_dict
[
"price"
]
=
str
(
fetch_dict
[
"price"
][
0
][
0
])
return
fetch_dict
return
fetch_dict
...
...
python/paddle_serving_server/web_service.py
浏览文件 @
6d74f2a8
...
@@ -29,7 +29,7 @@ class WebService(object):
...
@@ -29,7 +29,7 @@ class WebService(object):
def
__init__
(
self
,
name
=
"default_service"
):
def
__init__
(
self
,
name
=
"default_service"
):
self
.
name
=
name
self
.
name
=
name
# pipeline
# pipeline
self
.
_server
=
pipeline
.
PipelineServer
()
self
.
_server
=
pipeline
.
PipelineServer
(
self
.
name
)
def
get_pipeline_response
(
self
,
read_op
):
def
get_pipeline_response
(
self
,
read_op
):
return
None
return
None
...
...
python/paddle_serving_server_gpu/web_service.py
浏览文件 @
6d74f2a8
...
@@ -32,7 +32,7 @@ class WebService(object):
...
@@ -32,7 +32,7 @@ class WebService(object):
def
__init__
(
self
,
name
=
"default_service"
):
def
__init__
(
self
,
name
=
"default_service"
):
self
.
name
=
name
self
.
name
=
name
# pipeline
# pipeline
self
.
_server
=
pipeline
.
PipelineServer
()
self
.
_server
=
pipeline
.
PipelineServer
(
self
.
name
)
self
.
gpus
=
[]
# deprecated
self
.
gpus
=
[]
# deprecated
self
.
rpc_service_list
=
[]
# deprecated
self
.
rpc_service_list
=
[]
# deprecated
...
...
python/pipeline/channel.py
浏览文件 @
6d74f2a8
...
@@ -40,7 +40,8 @@ class ChannelDataEcode(enum.Enum):
...
@@ -40,7 +40,8 @@ class ChannelDataEcode(enum.Enum):
RPC_PACKAGE_ERROR
=
4
RPC_PACKAGE_ERROR
=
4
CLIENT_ERROR
=
5
CLIENT_ERROR
=
5
CLOSED_ERROR
=
6
CLOSED_ERROR
=
6
UNKNOW
=
7
NO_SERVICE
=
7
UNKNOW
=
8
class
ChannelDataType
(
enum
.
Enum
):
class
ChannelDataType
(
enum
.
Enum
):
...
...
python/pipeline/gateway/proto/gateway.proto
浏览文件 @
6d74f2a8
...
@@ -28,12 +28,13 @@ message Response {
...
@@ -28,12 +28,13 @@ message Response {
message
Request
{
message
Request
{
repeated
string
key
=
1
;
repeated
string
key
=
1
;
repeated
string
value
=
2
;
repeated
string
value
=
2
;
string
name
=
3
;
}
}
service
PipelineService
{
service
PipelineService
{
rpc
inference
(
Request
)
returns
(
Response
)
{
rpc
inference
(
Request
)
returns
(
Response
)
{
option
(
google.api.http
)
=
{
option
(
google.api.http
)
=
{
post
:
"/prediction"
post
:
"/
{name=*}/
prediction"
body
:
"*"
body
:
"*"
};
};
}
}
...
...
python/pipeline/pipeline_server.py
浏览文件 @
6d74f2a8
...
@@ -22,23 +22,31 @@ from contextlib import closing
...
@@ -22,23 +22,31 @@ from contextlib import closing
import
multiprocessing
import
multiprocessing
import
yaml
import
yaml
from
.proto
import
pipeline_service_pb2_grpc
from
.proto
import
pipeline_service_pb2_grpc
,
pipeline_service_pb2
from
.
import
operator
from
.
import
operator
from
.
import
dag
from
.
import
dag
from
.
import
util
from
.
import
util
from
.
import
channel
_LOGGER
=
logging
.
getLogger
(
__name__
)
_LOGGER
=
logging
.
getLogger
(
__name__
)
class
PipelineServicer
(
pipeline_service_pb2_grpc
.
PipelineServiceServicer
):
class
PipelineServicer
(
pipeline_service_pb2_grpc
.
PipelineServiceServicer
):
def
__init__
(
self
,
response_op
,
dag_conf
,
worker_idx
=-
1
):
def
__init__
(
self
,
name
,
response_op
,
dag_conf
,
worker_idx
=-
1
):
super
(
PipelineServicer
,
self
).
__init__
()
super
(
PipelineServicer
,
self
).
__init__
()
self
.
_name
=
name
# init dag executor
# init dag executor
self
.
_dag_executor
=
dag
.
DAGExecutor
(
response_op
,
dag_conf
,
worker_idx
)
self
.
_dag_executor
=
dag
.
DAGExecutor
(
response_op
,
dag_conf
,
worker_idx
)
self
.
_dag_executor
.
start
()
self
.
_dag_executor
.
start
()
_LOGGER
.
info
(
"[PipelineServicer] succ init"
)
_LOGGER
.
info
(
"[PipelineServicer] succ init"
)
def
inference
(
self
,
request
,
context
):
def
inference
(
self
,
request
,
context
):
if
request
.
name
!=
""
and
request
.
name
!=
self
.
_name
:
resp
=
pipeline_service_pb2
.
Response
()
resp
.
ecode
=
channel
.
ChannelDataEcode
.
NO_SERVICE
.
value
resp
.
error_info
=
"Failed to inference: Service name error."
return
resp
resp
=
self
.
_dag_executor
.
call
(
request
)
resp
=
self
.
_dag_executor
.
call
(
request
)
return
resp
return
resp
...
@@ -58,7 +66,8 @@ def _reserve_port(port):
...
@@ -58,7 +66,8 @@ def _reserve_port(port):
class
PipelineServer
(
object
):
class
PipelineServer
(
object
):
def
__init__
(
self
):
def
__init__
(
self
,
name
=
None
):
self
.
_name
=
name
# for grpc-gateway path
self
.
_rpc_port
=
None
self
.
_rpc_port
=
None
self
.
_worker_num
=
None
self
.
_worker_num
=
None
self
.
_response_op
=
None
self
.
_response_op
=
None
...
@@ -201,7 +210,8 @@ class PipelineServer(object):
...
@@ -201,7 +210,8 @@ class PipelineServer(object):
(
'grpc.max_receive_message_length'
,
256
*
1024
*
1024
)
(
'grpc.max_receive_message_length'
,
256
*
1024
*
1024
)
])
])
pipeline_service_pb2_grpc
.
add_PipelineServiceServicer_to_server
(
pipeline_service_pb2_grpc
.
add_PipelineServiceServicer_to_server
(
PipelineServicer
(
self
.
_response_op
,
self
.
_conf
),
server
)
PipelineServicer
(
self
.
_name
,
self
.
_response_op
,
self
.
_conf
),
server
)
server
.
add_insecure_port
(
'[::]:{}'
.
format
(
self
.
_rpc_port
))
server
.
add_insecure_port
(
'[::]:{}'
.
format
(
self
.
_rpc_port
))
server
.
start
()
server
.
start
()
self
.
_run_grpc_gateway
(
self
.
_run_grpc_gateway
(
...
@@ -217,7 +227,8 @@ class PipelineServer(object):
...
@@ -217,7 +227,8 @@ class PipelineServer(object):
futures
.
ThreadPoolExecutor
(
futures
.
ThreadPoolExecutor
(
max_workers
=
1
,
),
options
=
options
)
max_workers
=
1
,
),
options
=
options
)
pipeline_service_pb2_grpc
.
add_PipelineServiceServicer_to_server
(
pipeline_service_pb2_grpc
.
add_PipelineServiceServicer_to_server
(
PipelineServicer
(
response_op
,
dag_conf
,
worker_idx
),
server
)
PipelineServicer
(
self
.
_name
,
response_op
,
dag_conf
,
worker_idx
),
server
)
server
.
add_insecure_port
(
bind_address
)
server
.
add_insecure_port
(
bind_address
)
server
.
start
()
server
.
start
()
server
.
wait_for_termination
()
server
.
wait_for_termination
()
...
...
python/pipeline/proto/pipeline_service.proto
浏览文件 @
6d74f2a8
...
@@ -18,6 +18,7 @@ package baidu.paddle_serving.pipeline_serving;
...
@@ -18,6 +18,7 @@ package baidu.paddle_serving.pipeline_serving;
message
Request
{
message
Request
{
repeated
string
key
=
1
;
repeated
string
key
=
1
;
repeated
string
value
=
2
;
repeated
string
value
=
2
;
optional
string
name
=
3
;
};
};
message
Response
{
message
Response
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录