Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
32881e58
S
Serving
项目概览
PaddlePaddle
/
Serving
12 个月 前同步成功
通知
183
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
32881e58
编写于
1月 13, 2020
作者:
G
guru4elephant
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update python client api
上级
d0f30b33
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
65 addition
and
4 deletion
+65
-4
python/paddle_serving/serving_client/__init__.py
python/paddle_serving/serving_client/__init__.py
+60
-2
python/setup.py.in
python/setup.py.in
+5
-2
未找到文件。
python/paddle_serving/serving_client/__init__.py
浏览文件 @
32881e58
...
...
@@ -13,6 +13,51 @@
# limitations under the License.
from
.serving_client
import
PredictorClient
from
..proto
import
sdk_configure_pb2
as
sdk
import
time
class
SDKConfig
(
object
):
def
__init__
(
self
):
self
.
sdk_desc
=
sdk
.
SDKConf
()
self
.
endpoints
=
[]
def
set_server_endpoints
(
self
,
endpoints
):
self
.
endpoints
=
endpoints
def
gen_desc
(
self
):
predictor_desc
=
sdk
.
Predictor
()
predictor_desc
.
name
=
"general_model"
predictor_desc
.
service_name
=
\
"baidu.paddle_serving.predictor.general_model.GeneralModelService"
predictor_desc
.
endpoint_router
=
"WeightedRandomRender"
predictor_desc
.
weighted_random_render_conf
.
variant_weight_list
=
"30"
variant_desc
=
sdk
.
VariantConf
()
variant_desc
.
tag
=
"var1"
variant_desc
.
naming_conf
.
cluster
=
"list://%s"
.
format
(
":"
.
join
(
self
.
endpoints
))
predictor_desc
.
variants
.
extend
([
variant_desc
])
self
.
sdk_desc
.
predictors
.
extend
([
predictor_desc
])
self
.
sdk_desc
.
default_variant_conf
.
tag
=
"default"
self
.
sdk_desc
.
default_variant_conf
.
connection_conf
.
connect_timeout_ms
=
2000
self
.
sdk_desc
.
default_variant_conf
.
connection_conf
.
rpc_timeout_ms
=
20000
self
.
sdk_desc
.
default_variant_conf
.
connection_conf
.
connect_retry_count
=
2
self
.
sdk_desc
.
default_variant_conf
.
connection_conf
.
max_connection_per_host
=
100
self
.
sdk_desc
.
default_variant_conf
.
connection_conf
.
hedge_request_timeout_ms
=
-
1
self
.
sdk_desc
.
default_variant_conf
.
connection_conf
.
hedge_fetch_retry_count
=
2
self
.
sdk_desc
.
default_variant_conf
.
connection_conf
.
connection_type
=
"pooled"
self
.
sdk_desc
.
default_variant_conf
.
naming_conf
.
cluster_filter_strategy
=
"Default"
self
.
sdk_desc
.
default_variant_conf
.
naming_conf
.
load_balance_strategy
=
"la"
self
.
sdk_desc
.
default_variant_conf
.
rpc_parameter
.
compress_type
=
0
self
.
sdk_desc
.
default_variant_conf
.
rpc_parameter
.
package_size
=
20
self
.
sdk_desc
.
default_variant_conf
.
rpc_parameter
.
protocol
=
"baidu_std"
self
.
sdk_desc
.
default_variant_conf
.
rpc_parameter
.
max_channel_per_request
=
3
return
str
(
self
.
sdk_desc
)
class
Client
(
object
):
def
__init__
(
self
):
...
...
@@ -28,13 +73,26 @@ class Client(object):
# get feed vars, fetch vars
# get feed shapes, feed types
# map feed names to index
self
.
client_handle_
=
PredictorClient
()
self
.
client_handle_
.
init
(
path
)
return
def
connect
(
self
,
endpoint
):
def
connect
(
self
,
endpoint
s
):
# check whether current endpoint is available
# init from client config
# create predictor here
return
predictor_sdk
=
SDKConfig
()
predictor_sdk
.
set_server_endpoints
(
endpoints
)
sdk_desc
=
predictor_sdk
.
gen_desc
()
print
(
sdk_desc
)
timestamp
=
time
.
asctime
(
time
.
localtime
(
time
.
time
()))
predictor_path
=
"/tmp/"
predictor_file
=
"%s_predictor.conf"
%
timestamp
with
open
(
predictor_path
+
predictor_file
,
"w"
)
as
fout
:
fout
.
write
(
sdk_desc
)
self
.
client_handle_
.
set_predictor_conf
(
predictor_path
,
predictor_file
)
self
.
client_handle_
.
create_predictor
()
def
get_feed_names
(
self
):
return
self
.
feed_names_
...
...
python/setup.py.in
浏览文件 @
32881e58
...
...
@@ -33,10 +33,13 @@ REQUIRED_PACKAGES = [
]
packages=['paddle_serving',
'paddle_serving.serving_client']
'paddle_serving.serving_client',
'paddle_serving.proto']
package_data={'paddle_serving.serving_client': ['serving_client.so']}
package_dir={'paddle_serving.serving_client':
'${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving/serving_client'}
'${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving/serving_client',
'paddle_serving.proto':
'${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving/proto'}
setup(
name='paddle-serving-client',
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录