Remove metric_type check and fix some minor bugs (#24921)

Signed-off-by: zhenshan.cao <zhenshan.cao@zilliz.com>
Co-authored-by: zhenshan.cao <zhenshan.cao@zilliz.com>
This commit is contained in:
cai.zhang 2023-06-19 09:54:41 +08:00 committed by GitHub
parent 31c08a8135
commit c9e456c6eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 76 additions and 26 deletions

View File

@ -579,4 +579,4 @@ trace:
autoIndex:
params:
build: '{"M": 30,"efConstruction": 360,"index_type": "HNSW", "metric_type": "IP"}'
build: '{"M": 18,"efConstruction": 240,"index_type": "HNSW", "metric_type": "IP"}'

View File

@ -141,7 +141,7 @@ func parseSearchInfo(searchParamsPair []*commonpb.KeyValuePair) (*planpb.QueryIn
metricType, err := funcutil.GetAttrByKeyFromRepeatedKV(common.MetricTypeKey, searchParamsPair)
if err != nil {
return nil, 0, errors.New(common.MetricTypeKey + " not found in search_params")
metricType = ""
}
roundDecimalStr, err := funcutil.GetAttrByKeyFromRepeatedKV(RoundDecimalKey, searchParamsPair)

View File

@ -96,6 +96,19 @@ func createColl(t *testing.T, name string, rc types.RootCoord) {
require.NoError(t, createColT.PostExecute(ctx))
}
func getBaseSearchParams() []*commonpb.KeyValuePair {
return []*commonpb.KeyValuePair{
{
Key: AnnsFieldKey,
Value: testFloatVecField,
},
{
Key: TopKKey,
Value: "10",
},
}
}
func getValidSearchParams() []*commonpb.KeyValuePair {
return []*commonpb.KeyValuePair{
{
@ -1693,16 +1706,46 @@ func TestTaskSearch_parseQueryInfo(t *testing.T) {
t.Run("parseSearchInfo no error", func(t *testing.T) {
var targetOffset int64 = 200
sp := getValidSearchParams()
sp = append(sp, &commonpb.KeyValuePair{
normalParam := getValidSearchParams()
noMetricTypeParams := getBaseSearchParams()
noMetricTypeParams = append(noMetricTypeParams, &commonpb.KeyValuePair{
Key: SearchParamsKey,
Value: `{"nprobe": 10}`,
})
//noSearchParams := getBaseSearchParams()
//noSearchParams = append(noSearchParams, &commonpb.KeyValuePair{
// Key: common.MetricTypeKey,
// Value: distance.L2,
//})
offsetParam := getValidSearchParams()
offsetParam = append(offsetParam, &commonpb.KeyValuePair{
Key: OffsetKey,
Value: strconv.FormatInt(targetOffset, 10),
})
info, offset, err := parseSearchInfo(sp)
assert.NoError(t, err)
assert.NotNil(t, info)
assert.Equal(t, targetOffset, offset)
tests := []struct {
description string
validParams []*commonpb.KeyValuePair
}{
{"noMetricType", noMetricTypeParams},
//{"noSearchParams", noSearchParams},
{"normal", normalParam},
{"offsetParam", offsetParam},
}
for _, test := range tests {
t.Run(test.description, func(t *testing.T) {
info, offset, err := parseSearchInfo(test.validParams)
assert.NoError(t, err)
assert.NotNil(t, info)
if test.description == "offsetParam" {
assert.Equal(t, targetOffset, offset)
}
})
}
})
t.Run("parseSearchInfo error", func(t *testing.T) {
@ -1774,8 +1817,6 @@ func TestTaskSearch_parseQueryInfo(t *testing.T) {
{"Invalid_topk", spInvalidTopk},
{"Invalid_topk_65536", spInvalidTopk65536},
{"Invalid_topk_plus_offset", spInvalidTopkPlusOffset},
{"No_Metric_type", spNoMetricType},
{"No_search_params", spNoSearchParams},
{"Invalid_round_decimal", spInvalidRoundDecimal},
{"Invalid_round_decimal_1000", spInvalidRoundDecimal2},
{"Invalid_offset_not_int", spInvalidOffsetNoInt},

View File

@ -49,7 +49,7 @@ func (p *autoIndexConfig) init(base *BaseTable) {
p.IndexParams = ParamItem{
Key: "autoIndex.params.build",
Version: "2.2.0",
DefaultValue: `{"M": 30,"efConstruction": 360,"index_type": "HNSW", "metric_type": "IP"}`,
DefaultValue: `{"M": 18,"efConstruction": 240,"index_type": "HNSW", "metric_type": "IP"}`,
}
p.IndexParams.Init(base.mgr)

View File

@ -101,6 +101,21 @@ get_invalid_strs = [
"%$#",
"".join("a" for i in range(max_name_length + 1))]
get_invalid_type_fields = [
1,
[1, "2", 3],
(1,),
{1: 1},
None,
"",
" ",
"12-s",
"12 s",
"(mn)",
"中文",
"%$#",
"".join("a" for i in range(max_name_length + 1))]
get_not_string = [
[],
{},
@ -174,7 +189,6 @@ get_invalid_metric_type = [
[1, "2", 3],
(1,),
{1: 1},
None,
" ",
"12-s",
"12 s",

View File

@ -12,7 +12,7 @@ allure-pytest==2.7.0
pytest-print==0.2.1
pytest-level==0.1.1
pytest-xdist==2.5.0
pymilvus==2.4.0.dev67
pymilvus==2.4.0.dev73
pytest-rerunfailures==9.1.1
git+https://github.com/Projectplace/pytest-tags
ndg-httpsclient
@ -43,4 +43,4 @@ loguru==0.6.0
# util
psutil==5.9.4
# for standby test
etcd-sdk-python==0.0.2
etcd-sdk-python==0.0.2

View File

@ -59,7 +59,7 @@ class TestCollectionParams(TestcaseBase):
pytest.skip("None schema is valid")
yield request.param
@pytest.fixture(scope="function", params=ct.get_invalid_strs)
@pytest.fixture(scope="function", params=ct.get_invalid_type_fields)
def get_invalid_type_fields(self, request):
if isinstance(request.param, list):
pytest.skip("list is valid fields")
@ -734,10 +734,9 @@ class TestCollectionParams(TestcaseBase):
self._connect()
int_field = cf.gen_int64_field(is_primary=True, auto_id=True)
vec_field = cf.gen_float_vec_field(name='vec')
error = {ct.err_code: 0, ct.err_msg: "The auto_id of the collection is inconsistent with "
"the auto_id of the primary key field"}
self.collection_schema_wrap.init_collection_schema([int_field, vec_field], auto_id=False,
check_task=CheckTasks.err_res, check_items=error)
schema, _ = self.collection_schema_wrap.init_collection_schema([int_field, vec_field], auto_id=False)
assert schema.auto_id
@pytest.mark.tags(CaseLabel.L2)
@pytest.mark.parametrize("auto_id", [True, False])
@ -3759,14 +3758,10 @@ class TestCollectionString(TestcaseBase):
vec_field = cf.gen_float_vec_field()
string_field = cf.gen_string_field(is_primary=True, auto_id=True)
fields = [int_field, string_field, vec_field]
schema, _ = self.collection_schema_wrap.init_collection_schema(fields=fields)
# error = {ct.err_code: 0, ct.err_msg: "autoID is not supported when the VarChar field is the primary key"}
c_name = cf.gen_unique_str(prefix)
self.collection_wrap.init_collection(name=c_name, schema=schema,
check_task=CheckTasks.check_collection_property,
check_items={exp_name: c_name, exp_schema: schema})
error = {ct.err_code: 0, ct.err_msg: "The auto_id can only be specified on field with DataType.INT64"}
self.collection_schema_wrap.init_collection_schema(fields=fields,
check_task=CheckTasks.err_res, check_items=error)
class TestCollectionJSON(TestcaseBase):
"""
******************************************************************