Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
12223136
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看板
提交
12223136
编写于
8月 18, 2020
作者:
B
barriery
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add code for gateway
上级
d3047448
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
97 addition
and
1 deletion
+97
-1
python/examples/pipeline/grpc-gateway/gateway/gateway.proto
python/examples/pipeline/grpc-gateway/gateway/gateway.proto
+40
-0
python/examples/pipeline/grpc-gateway/gateway/gen_code.sh
python/examples/pipeline/grpc-gateway/gateway/gen_code.sh
+13
-0
python/examples/pipeline/grpc-gateway/proxy_server.go
python/examples/pipeline/grpc-gateway/proxy_server.go
+43
-0
python/pipeline/pipeline_client.py
python/pipeline/pipeline_client.py
+1
-1
未找到文件。
python/examples/pipeline/grpc-gateway/gateway/gateway.proto
0 → 100644
浏览文件 @
12223136
// Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax
=
"proto3"
;
package
baidu
.
paddle_serving.pipeline_serving
;
option
go_package
=
".;pipeline_gateway"
;
import
"google/api/annotations.proto"
;
message
Response
{
repeated
string
key
=
1
;
repeated
string
value
=
2
;
int32
ecode
=
3
;
string
error_info
=
4
;
};
message
Request
{
repeated
string
key
=
1
;
repeated
string
value
=
2
;
}
service
PipelineService
{
rpc
inference
(
Request
)
returns
(
Response
)
{
option
(
google.api.http
)
=
{
post
:
"/pipeline/prediction"
body
:
"*"
};
}
};
python/examples/pipeline/grpc-gateway/gateway/gen_code.sh
0 → 100644
浏览文件 @
12223136
# generate <path/to/your_service>.pb.go
protoc
-I
/usr/local/include
-I
.
\
-I
$GOPATH
/src
\
-I
$GOPATH
/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis
\
--go_out
=
plugins
=
grpc:.
\
gateway.proto
# generate <path/to/your_service>.gw.go
protoc
-I
/usr/local/include
-I
.
\
-I
$GOPATH
/src
\
-I
$GOPATH
/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis
\
--grpc-gateway_out
=
logtostderr
=
true
:.
\
gateway.proto
python/examples/pipeline/grpc-gateway/proxy_server.go
0 → 100644
浏览文件 @
12223136
package
main
import
(
"flag"
"net/http"
"log"
"github.com/golang/glog"
"golang.org/x/net/context"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"google.golang.org/grpc"
gw
"./gateway"
)
var
(
pipelineEndpoint
=
flag
.
String
(
"pipeline_endpoint"
,
"localhost:18080"
,
"endpoint of PipelineService"
)
)
func
run
()
error
{
ctx
:=
context
.
Background
()
ctx
,
cancel
:=
context
.
WithCancel
(
ctx
)
defer
cancel
()
mux
:=
runtime
.
NewServeMux
()
opts
:=
[]
grpc
.
DialOption
{
grpc
.
WithInsecure
()}
err
:=
gw
.
RegisterPipelineServiceHandlerFromEndpoint
(
ctx
,
mux
,
*
pipelineEndpoint
,
opts
)
if
err
!=
nil
{
return
err
}
log
.
Println
(
"start service"
)
return
http
.
ListenAndServe
(
":8080"
,
mux
)
// proxy port
}
func
main
()
{
flag
.
Parse
()
defer
glog
.
Flush
()
if
err
:=
run
();
err
!=
nil
{
glog
.
Fatal
(
err
)
}
}
python/pipeline/pipeline_client.py
浏览文件 @
12223136
...
...
@@ -46,7 +46,7 @@ class PipelineClient(object):
req
.
key
.
append
(
key
)
if
isinstance
(
value
,
np
.
ndarray
):
req
.
value
.
append
(
value
.
__repr__
())
elif
isinstance
(
value
,
str
):
elif
isinstance
(
value
,
(
str
,
unicode
)
):
req
.
value
.
append
(
value
)
elif
isinstance
(
value
,
list
):
req
.
value
.
append
(
np
.
array
(
value
).
__repr__
())
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录