Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
4e562181
M
milvus
项目概览
milvus
/
milvus
11 个月 前同步成功
通知
261
Star
22476
Fork
2472
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
milvus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
4e562181
编写于
6月 24, 2021
作者:
B
binbin
提交者:
GitHub
6月 24, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add test cases for search after dev changes (#6092)
Signed-off-by:
N
Binbin Lv
<
binbin.lv@zilliz.com
>
上级
f633d48c
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
592 addition
and
151 deletion
+592
-151
tests20/python_client/base/client_base.py
tests20/python_client/base/client_base.py
+9
-8
tests20/python_client/common/common_func.py
tests20/python_client/common/common_func.py
+65
-4
tests20/python_client/common/common_type.py
tests20/python_client/common/common_type.py
+5
-0
tests20/python_client/testcases/test_search.py
tests20/python_client/testcases/test_search.py
+513
-139
未找到文件。
tests20/python_client/base/client_base.py
浏览文件 @
4e562181
...
...
@@ -143,7 +143,8 @@ class TestcaseBase(Base):
**
kwargs
)
return
partition_wrap
def
init_collection_general
(
self
,
prefix
,
insert_data
=
False
,
nb
=
ct
.
default_nb
,
partition_num
=
0
,
is_binary
=
False
):
def
init_collection_general
(
self
,
prefix
,
insert_data
=
False
,
nb
=
ct
.
default_nb
,
partition_num
=
0
,
is_binary
=
False
,
is_all_data_type
=
False
):
"""
target: create specified collections
method: 1. create collections (binary/non-binary)
...
...
@@ -158,10 +159,11 @@ class TestcaseBase(Base):
vectors
=
[]
binary_raw_vectors
=
[]
# 1 create collection
default_schema
=
cf
.
gen_default_collection_schema
()
if
is_binary
:
default_schema
=
cf
.
gen_default_binary_collection_schema
()
els
e
:
default_schema
=
cf
.
gen_
default_collection_schema
()
if
is_all_data_typ
e
:
default_schema
=
cf
.
gen_
collection_schema_all_datatype
()
log
.
info
(
"init_collection_general: collection creation"
)
collection_w
=
self
.
init_collection_wrap
(
name
=
collection_name
,
schema
=
default_schema
)
...
...
@@ -170,11 +172,10 @@ class TestcaseBase(Base):
cf
.
gen_partitions
(
collection_w
,
partition_num
)
# 3 insert data if specified
if
insert_data
:
collection_w
,
vectors
,
binary_raw_vectors
=
cf
.
insert_data
(
collection_w
,
nb
,
is_binary
)
if
nb
<=
32000
:
conn
.
flush
([
collection_w
.
name
])
assert
collection_w
.
is_empty
==
False
assert
collection_w
.
num_entities
==
nb
collection_w
,
vectors
,
binary_raw_vectors
=
\
cf
.
insert_data
(
collection_w
,
nb
,
is_binary
,
is_all_data_type
)
assert
collection_w
.
is_empty
==
False
assert
collection_w
.
num_entities
==
nb
collection_w
.
load
()
return
collection_w
,
vectors
,
binary_raw_vectors
tests20/python_client/common/common_func.py
浏览文件 @
4e562181
...
...
@@ -25,6 +25,30 @@ def gen_str_by_length(length=8):
return
""
.
join
(
random
.
choice
(
string
.
ascii_letters
+
string
.
digits
)
for
_
in
range
(
length
))
def
gen_bool_field
(
name
=
ct
.
default_bool_field_name
,
description
=
ct
.
default_desc
,
is_primary
=
False
,
**
kwargs
):
bool_field
,
_
=
ApiFieldSchemaWrapper
().
init_field_schema
(
name
=
name
,
dtype
=
DataType
.
BOOL
,
description
=
description
,
is_primary
=
is_primary
,
**
kwargs
)
return
bool_field
def
gen_int8_field
(
name
=
ct
.
default_int8_field_name
,
description
=
ct
.
default_desc
,
is_primary
=
False
,
**
kwargs
):
int8_field
,
_
=
ApiFieldSchemaWrapper
().
init_field_schema
(
name
=
name
,
dtype
=
DataType
.
INT8
,
description
=
description
,
is_primary
=
is_primary
,
**
kwargs
)
return
int8_field
def
gen_int16_field
(
name
=
ct
.
default_int16_field_name
,
description
=
ct
.
default_desc
,
is_primary
=
False
,
**
kwargs
):
int16_field
,
_
=
ApiFieldSchemaWrapper
().
init_field_schema
(
name
=
name
,
dtype
=
DataType
.
INT16
,
description
=
description
,
is_primary
=
is_primary
,
**
kwargs
)
return
int16_field
def
gen_int32_field
(
name
=
ct
.
default_int32_field_name
,
description
=
ct
.
default_desc
,
is_primary
=
False
,
**
kwargs
):
int32_field
,
_
=
ApiFieldSchemaWrapper
().
init_field_schema
(
name
=
name
,
dtype
=
DataType
.
INT32
,
description
=
description
,
is_primary
=
is_primary
,
**
kwargs
)
return
int32_field
def
gen_int64_field
(
name
=
ct
.
default_int64_field_name
,
description
=
ct
.
default_desc
,
is_primary
=
False
,
**
kwargs
):
int64_field
,
_
=
ApiFieldSchemaWrapper
().
init_field_schema
(
name
=
name
,
dtype
=
DataType
.
INT64
,
description
=
description
,
is_primary
=
is_primary
,
**
kwargs
)
...
...
@@ -37,6 +61,12 @@ def gen_float_field(name=ct.default_float_field_name, is_primary=False, descript
return
float_field
def
gen_double_field
(
name
=
ct
.
default_double_field_name
,
is_primary
=
False
,
description
=
ct
.
default_desc
):
double_field
,
_
=
ApiFieldSchemaWrapper
().
init_field_schema
(
name
=
name
,
dtype
=
DataType
.
DOUBLE
,
description
=
description
,
is_primary
=
is_primary
)
return
double_field
def
gen_float_vec_field
(
name
=
ct
.
default_float_vec_field_name
,
is_primary
=
False
,
dim
=
ct
.
default_dim
,
description
=
ct
.
default_desc
):
float_vec_field
,
_
=
ApiFieldSchemaWrapper
().
init_field_schema
(
name
=
name
,
dtype
=
DataType
.
FLOAT_VECTOR
,
...
...
@@ -61,6 +91,16 @@ def gen_default_collection_schema(description=ct.default_desc, primary_field=ct.
return
schema
def
gen_collection_schema_all_datatype
(
description
=
ct
.
default_desc
,
primary_field
=
ct
.
default_int64_field_name
,
auto_id
=
False
):
fields
=
[
gen_int64_field
(),
gen_int32_field
(),
gen_int16_field
(),
gen_int8_field
(),
gen_bool_field
(),
gen_float_field
(),
gen_double_field
(),
gen_float_vec_field
()]
schema
,
_
=
ApiCollectionSchemaWrapper
().
init_collection_schema
(
fields
=
fields
,
description
=
description
,
primary_field
=
primary_field
,
auto_id
=
auto_id
)
return
schema
def
gen_collection_schema
(
fields
,
primary_field
=
None
,
description
=
ct
.
default_desc
,
auto_id
=
False
):
schema
,
_
=
ApiCollectionSchemaWrapper
().
init_collection_schema
(
fields
=
fields
,
primary_field
=
primary_field
,
description
=
description
,
auto_id
=
auto_id
)
...
...
@@ -101,6 +141,27 @@ def gen_default_dataframe_data(nb=ct.default_nb, dim=ct.default_dim, start=0):
})
return
df
def
gen_dataframe_all_data_type
(
nb
=
ct
.
default_nb
,
dim
=
ct
.
default_dim
,
start
=
0
):
int64_values
=
pd
.
Series
(
data
=
[
i
for
i
in
range
(
start
,
start
+
nb
)])
int32_values
=
pd
.
Series
(
data
=
[
np
.
int32
(
i
)
for
i
in
range
(
start
,
start
+
nb
)],
dtype
=
"int32"
)
int16_values
=
pd
.
Series
(
data
=
[
np
.
int16
(
i
)
for
i
in
range
(
start
,
start
+
nb
)],
dtype
=
"int16"
)
int8_values
=
pd
.
Series
(
data
=
[
np
.
int8
(
i
)
for
i
in
range
(
start
,
start
+
nb
)],
dtype
=
"int8"
)
bool_values
=
pd
.
Series
(
data
=
[
np
.
bool
(
i
)
for
i
in
range
(
start
,
start
+
nb
)],
dtype
=
"bool"
)
float_values
=
pd
.
Series
(
data
=
[
float
(
i
)
for
i
in
range
(
start
,
start
+
nb
)],
dtype
=
"float32"
)
double_values
=
pd
.
Series
(
data
=
[
np
.
double
(
i
)
for
i
in
range
(
start
,
start
+
nb
)],
dtype
=
"double"
)
float_vec_values
=
gen_vectors
(
nb
,
dim
)
df
=
pd
.
DataFrame
({
ct
.
default_int64_field_name
:
int64_values
,
ct
.
default_int32_field_name
:
int32_values
,
ct
.
default_int16_field_name
:
int16_values
,
ct
.
default_int8_field_name
:
int8_values
,
ct
.
default_bool_field_name
:
bool_values
,
ct
.
default_float_field_name
:
float_values
,
ct
.
default_double_field_name
:
double_values
,
ct
.
default_float_vec_field_name
:
float_vec_values
})
return
df
def
gen_default_binary_dataframe_data
(
nb
=
ct
.
default_nb
,
dim
=
ct
.
default_dim
,
start
=
0
):
int_values
=
pd
.
Series
(
data
=
[
i
for
i
in
range
(
start
,
start
+
nb
)])
...
...
@@ -190,7 +251,6 @@ def gen_normal_expressions():
]
return
expressions
def
jaccard
(
x
,
y
):
x
=
np
.
asarray
(
x
,
np
.
bool
)
y
=
np
.
asarray
(
y
,
np
.
bool
)
...
...
@@ -278,7 +338,7 @@ def gen_partitions(collection_w, partition_num=1):
log
.
info
(
"gen_partitions: created partitions %s"
%
par
)
def
insert_data
(
collection_w
,
nb
=
3000
,
is_binary
=
False
):
def
insert_data
(
collection_w
,
nb
=
3000
,
is_binary
=
False
,
is_all_data_type
=
False
):
"""
target: insert non-binary/binary data
method: insert non-binary/binary data into partitions if any
...
...
@@ -291,11 +351,12 @@ def insert_data(collection_w, nb=3000, is_binary=False):
log
.
info
(
"insert_data: inserting data into collection %s (num_entities: %s)"
%
(
collection_w
.
name
,
nb
))
for
i
in
range
(
num
):
default_data
=
gen_default_dataframe_data
(
nb
//
num
)
if
is_binary
:
default_data
,
binary_raw_data
=
gen_default_binary_dataframe_data
(
nb
//
num
)
binary_raw_vectors
.
extend
(
binary_raw_data
)
els
e
:
default_data
=
gen_d
efault_dataframe_data
(
nb
//
num
)
if
is_all_data_typ
e
:
default_data
=
gen_d
ataframe_all_data_type
(
nb
//
num
)
collection_w
.
insert
(
default_data
,
par
[
i
].
name
)
vectors
.
append
(
default_data
)
log
.
info
(
"insert_data: inserted data into collection %s (num_entities: %s)"
...
...
tests20/python_client/common/common_type.py
浏览文件 @
4e562181
...
...
@@ -17,8 +17,13 @@ max_partition_num = 4096 # 256
default_segment_row_limit
=
1000
default_server_segment_row_limit
=
1024
*
512
default_alias
=
"default"
default_bool_field_name
=
"bool"
default_int8_field_name
=
"int8"
default_int16_field_name
=
"int16"
default_int32_field_name
=
"int32"
default_int64_field_name
=
"int64"
default_float_field_name
=
"float"
default_double_field_name
=
"double"
default_float_vec_field_name
=
"float_vector"
default_binary_vec_field_name
=
"binary_vector"
default_partition_name
=
"_default"
...
...
tests20/python_client/testcases/test_search.py
浏览文件 @
4e562181
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录