Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
109fa2b4
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看板
提交
109fa2b4
编写于
1月 14, 2020
作者:
G
guru4elephant
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix python client
上级
a4b2820d
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
123 addition
and
6 deletion
+123
-6
core/general-client/include/general_model.h
core/general-client/include/general_model.h
+1
-0
core/general-client/src/general_model.cpp
core/general-client/src/general_model.cpp
+3
-0
examples/demo-serving/kvdb/LOG
examples/demo-serving/kvdb/LOG
+55
-1
python/examples/imdb/inference.conf
python/examples/imdb/inference.conf
+6
-0
python/examples/imdb/test_client.py
python/examples/imdb/test_client.py
+16
-0
python/examples/util/get_acc.py
python/examples/util/get_acc.py
+13
-0
python/paddle_serving/serving_client/__init__.py
python/paddle_serving/serving_client/__init__.py
+29
-5
未找到文件。
core/general-client/include/general_model.h
浏览文件 @
109fa2b4
...
...
@@ -77,6 +77,7 @@ class PredictorClient {
std
::
map
<
std
::
string
,
int
>
_fetch_name_to_idx
;
std
::
map
<
std
::
string
,
std
::
string
>
_fetch_name_to_var_name
;
std
::
vector
<
std
::
vector
<
int
>
>
_shape
;
std
::
vector
<
int
>
_type
;
};
}
// namespace general_model
...
...
core/general-client/src/general_model.cpp
浏览文件 @
109fa2b4
...
...
@@ -45,6 +45,7 @@ void PredictorClient::init(const std::string & conf_file) {
std
::
string
fetch_var_name
;
int
shape_num
=
0
;
int
dim
=
0
;
int
type_value
=
0
;
for
(
int
i
=
0
;
i
<
feed_var_num
;
++
i
)
{
fin
>>
name
;
_feed_name_to_idx
[
name
]
=
i
;
...
...
@@ -54,6 +55,8 @@ void PredictorClient::init(const std::string & conf_file) {
fin
>>
dim
;
tmp_feed_shape
.
push_back
(
dim
);
}
fin
>>
type_value
;
_type
.
push_back
(
type_value
);
_shape
.
push_back
(
tmp_feed_shape
);
}
...
...
examples/demo-serving/kvdb/LOG
浏览文件 @
109fa2b4
...
...
@@ -22041,4 +22041,58 @@ AddFile(L0 Files): cumulative 0, interval 0
AddFile(Keys): cumulative 0, interval 0
Cumulative compaction: 0.00 GB write, 0.00 MB/s write, 0.00 GB read, 0.00 MB/s read, 0.0 seconds
Interval compaction: 0.00 GB write, 0.00 MB/s write, 0.00 GB read, 0.00 MB/s read, 0.0 seconds
Stalls(count): 0 level0_slowdown, 0 level0_
\ No newline at end of file
Stalls(count): 0 level0_slowdown, 0 level0_slowdown_with_compaction, 0 level0_numfiles, 0 level0_numfiles_with_compaction, 0 stop for pending_compaction_bytes, 0 slowdown for pending_compaction_bytes, 0 memtable_compaction, 0 memtable_slowdown, interval 0 total count
** File Read Latency Histogram By Level [default] **
2020/01/14-10:37:24.283818 7fcc9bdf2700 [/db_impl.cc:779] ------- DUMPING STATS -------
2020/01/14-10:37:24.283872 7fcc9bdf2700 [/db_impl.cc:780]
** DB Stats **
Uptime(secs): 252000.1 total, 600.0 interval
Cumulative writes: 0 writes, 0 keys, 0 commit groups, 0.0 writes per commit group, ingest: 0.00 GB, 0.00 MB/s
Cumulative WAL: 0 writes, 0 syncs, 0.00 writes per sync, written: 0.00 GB, 0.00 MB/s
Cumulative stall: 00:00:0.000 H:M:S, 0.0 percent
Interval writes: 0 writes, 0 keys, 0 commit groups, 0.0 writes per commit group, ingest: 0.00 MB, 0.00 MB/s
Interval WAL: 0 writes, 0 syncs, 0.00 writes per sync, written: 0.00 MB, 0.00 MB/s
Interval stall: 00:00:0.000 H:M:S, 0.0 percent
** Compaction Stats [default] **
Level Files Size Score Read(GB) Rn(GB) Rnp1(GB) Write(GB) Wnew(GB) Moved(GB) W-Amp Rd(MB/s) Wr(MB/s) Comp(sec) CompMergeCPU(sec) Comp(cnt) Avg(sec) KeyIn KeyDrop
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Sum 0/0 0.00 KB 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.00 0.00 0 0.000 0 0
Int 0/0 0.00 KB 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.00 0.00 0 0.000 0 0
** Compaction Stats [default] **
Priority Files Size Score Read(GB) Rn(GB) Rnp1(GB) Write(GB) Wnew(GB) Moved(GB) W-Amp Rd(MB/s) Wr(MB/s) Comp(sec) CompMergeCPU(sec) Comp(cnt) Avg(sec) KeyIn KeyDrop
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Uptime(secs): 252000.1 total, 600.0 interval
Flush(GB): cumulative 0.000, interval 0.000
AddFile(GB): cumulative 0.000, interval 0.000
AddFile(Total Files): cumulative 0, interval 0
AddFile(L0 Files): cumulative 0, interval 0
AddFile(Keys): cumulative 0, interval 0
Cumulative compaction: 0.00 GB write, 0.00 MB/s write, 0.00 GB read, 0.00 MB/s read, 0.0 seconds
Interval compaction: 0.00 GB write, 0.00 MB/s write, 0.00 GB read, 0.00 MB/s read, 0.0 seconds
Stalls(count): 0 level0_slowdown, 0 level0_slowdown_with_compaction, 0 level0_numfiles, 0 level0_numfiles_with_compaction, 0 stop for pending_compaction_bytes, 0 slowdown for pending_compaction_bytes, 0 memtable_compaction, 0 memtable_slowdown, interval 0 total count
** File Read Latency Histogram By Level [default] **
** Compaction Stats [default] **
Level Files Size Score Read(GB) Rn(GB) Rnp1(GB) Write(GB) Wnew(GB) Moved(GB) W-Amp Rd(MB/s) Wr(MB/s) Comp(sec) CompMergeCPU(sec) Comp(cnt) Avg(sec) KeyIn KeyDrop
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Sum 0/0 0.00 KB 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.00 0.00 0 0.000 0 0
Int 0/0 0.00 KB 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.00 0.00 0 0.000 0 0
** Compaction Stats [default] **
Priority Files Size Score Read(GB) Rn(GB) Rnp1(GB) Write(GB) Wnew(GB) Moved(GB) W-Amp Rd(MB/s) Wr(MB/s) Comp(sec) CompMergeCPU(sec) Comp(cnt) Avg(sec) KeyIn KeyDrop
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Uptime(secs): 252000.1 total, 0.0 interval
Flush(GB): cumulative 0.000, interval 0.000
AddFile(GB): cumulative 0.000, interval 0.000
AddFile(Total Files): cumulative 0, interval 0
AddFile(L0 Files): cumulative 0, interval 0
AddFile(Keys): cumulative 0, interval 0
Cumulative compaction: 0.00 GB write, 0.00 MB/s write, 0.00 GB read, 0.00 MB/s read, 0.0 seconds
Interval compaction: 0.00 GB write, 0.00 MB/s write, 0.00 GB read, 0.00 MB/s read, 0.0 seconds
Stalls(count): 0 level0_slowdown, 0 level0_slowdown_with_compaction, 0 level0_numfiles, 0 level0_numfiles_with_compaction, 0 stop for pending_compaction_bytes, 0 slowdown for pending_compaction_bytes, 0 memtable_compaction, 0 memtable_slowdown, interval 0 total count
** File Read Latency Histogram By Level [default] **
python/examples/imdb/inference.conf
0 → 100644
浏览文件 @
109fa2b4
2
3
words
1
-
1
0
label
1
1
0
cost
mean_0
.
tmp_0
acc
accuracy_0
.
tmp_0
prediction
fc_1
.
tmp_2
python/examples/imdb/test_client.py
0 → 100644
浏览文件 @
109fa2b4
from
paddle_serving
import
Client
import
sys
client
=
Client
()
client
.
load_client_config
(
sys
.
argv
[
1
])
client
.
connect
([
"127.0.0.1:9292"
])
for
line
in
sys
.
stdin
:
group
=
line
.
strip
().
split
()
words
=
[
int
(
x
)
for
x
in
group
[
1
:
int
(
group
[
0
])]]
label
=
[
int
(
group
[
-
1
])]
feed
=
{
"words"
:
words
,
"label"
:
label
}
fetch
=
[
"acc"
,
"cost"
,
"prediction"
]
fetch_map
=
client
.
predict
(
feed
=
feed
,
fetch
=
fetch
)
print
(
"{} {}"
.
format
(
fetch_map
[
"prediction"
][
1
],
label
[
0
]))
python/examples/util/get_acc.py
0 → 100644
浏览文件 @
109fa2b4
import
sys
import
os
total
=
0
acc
=
0
for
line
in
sys
.
stdin
:
line
=
line
.
strip
()
group
=
line
.
split
()
if
(
float
(
group
[
0
])
-
0.5
)
*
(
float
(
group
[
1
])
-
0.5
)
>
0
:
acc
+=
1
total
+=
1
print
(
float
(
acc
)
/
float
(
total
))
python/paddle_serving/serving_client/__init__.py
浏览文件 @
109fa2b4
...
...
@@ -16,6 +16,9 @@ from .serving_client import PredictorClient
from
..proto
import
sdk_configure_pb2
as
sdk
import
time
int_type
=
0
float_type
=
1
class
SDKConfig
(
object
):
def
__init__
(
self
):
self
.
sdk_desc
=
sdk
.
SDKConf
()
...
...
@@ -65,7 +68,7 @@ class Client(object):
self
.
fetch_names_
=
[]
self
.
client_handle_
=
None
self
.
feed_shapes_
=
[]
self
.
feed_types_
=
[]
self
.
feed_types_
=
{}
self
.
feed_names_to_idx_
=
{}
def
load_client_config
(
self
,
path
):
...
...
@@ -75,6 +78,28 @@ class Client(object):
# map feed names to index
self
.
client_handle_
=
PredictorClient
()
self
.
client_handle_
.
init
(
path
)
self
.
feed_names_
=
[]
self
.
fetch_names_
=
[]
self
.
feed_shapes_
=
[]
self
.
feed_types_
=
{}
self
.
feed_names_to_idx_
=
{}
with
open
(
path
)
as
fin
:
group
=
fin
.
readline
().
strip
().
split
()
feed_num
=
int
(
group
[
0
])
fetch_num
=
int
(
group
[
1
])
for
i
in
range
(
feed_num
):
group
=
fin
.
readline
().
strip
().
split
()
self
.
feed_names_
.
append
(
group
[
0
])
tmp_shape
=
[]
for
s
in
group
[
2
:
-
1
]:
tmp_shape
.
append
(
int
(
s
))
self
.
feed_shapes_
.
append
(
tmp_shape
)
self
.
feed_types_
[
group
[
0
]]
=
int
(
group
[
-
1
])
self
.
feed_names_to_idx_
[
group
[
0
]]
=
i
for
i
in
range
(
fetch_num
):
group
=
fin
.
readline
().
strip
().
split
()
self
.
fetch_names_
.
append
(
group
[
0
])
return
def
connect
(
self
,
endpoints
):
...
...
@@ -84,7 +109,6 @@ class Client(object):
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
...
...
@@ -100,7 +124,7 @@ class Client(object):
def
get_fetch_names
(
self
):
return
self
.
fetch_names_
def
predict
(
self
,
feed
=
{},
fetch
=
{}
):
def
predict
(
self
,
feed
=
{},
fetch
=
[]
):
int_slot
=
[]
float_slot
=
[]
int_feed_names
=
[]
...
...
@@ -111,10 +135,10 @@ class Client(object):
continue
if
self
.
feed_types_
[
key
]
==
int_type
:
int_feed_names
.
append
(
key
)
int_slot
.
append
(
feed
_map
[
key
])
int_slot
.
append
(
feed
[
key
])
elif
self
.
feed_types_
[
key
]
==
float_type
:
float_feed_names
.
append
(
key
)
float_slot
.
append
(
feed
_map
[
key
])
float_slot
.
append
(
feed
[
key
])
for
key
in
fetch
:
if
key
in
self
.
fetch_names_
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录