mirror of https://github.com/milvus-io/milvus.git
parent
e7b3bacbec
commit
4d46aa5331
|
@ -53,10 +53,12 @@ class ApiCollectionWrapper:
|
|||
|
||||
@property
|
||||
def is_empty(self):
|
||||
self.flush()
|
||||
return self.collection.is_empty
|
||||
|
||||
@property
|
||||
def num_entities(self):
|
||||
self.flush()
|
||||
return self.collection.num_entities
|
||||
|
||||
@property
|
||||
|
@ -120,22 +122,33 @@ class ApiCollectionWrapper:
|
|||
**kwargs).run()
|
||||
return res, check_result
|
||||
|
||||
# @trace()
|
||||
# def flush(self, check_task=None, check_items=None, **kwargs):
|
||||
# #TODO:currently, flush is not supported by sdk in milvus
|
||||
# timeout = kwargs.get("timeout", TIMEOUT)
|
||||
#
|
||||
# @timeout_decorator.timeout(timeout, timeout_exception=TimeoutError)
|
||||
# def _flush():
|
||||
# res = self.collection.num_entities
|
||||
# return res
|
||||
# try:
|
||||
# res = _flush()
|
||||
# return res, True
|
||||
# except TimeoutError as e:
|
||||
# log.error(f"flush timeout error: {e}")
|
||||
# res = None
|
||||
# return res, False
|
||||
|
||||
@trace()
|
||||
def flush(self, check_task=None, check_items=None, **kwargs):
|
||||
#TODO:currently, flush is not supported by sdk in milvus
|
||||
timeout = kwargs.get("timeout", TIMEOUT)
|
||||
|
||||
@timeout_decorator.timeout(timeout, timeout_exception=TimeoutError)
|
||||
def _flush():
|
||||
res = self.collection.num_entities
|
||||
return res
|
||||
try:
|
||||
res = _flush()
|
||||
return res, True
|
||||
except TimeoutError as e:
|
||||
log.error(f"flush timeout error: {e}")
|
||||
res = None
|
||||
return res, False
|
||||
kwargs.update({"timeout": timeout})
|
||||
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = api_request([self.collection.flush], **kwargs)
|
||||
check_result = ResponseChecker(res, func_name, check_task,
|
||||
check_items, check, **kwargs).run()
|
||||
return res, check_result
|
||||
|
||||
@trace()
|
||||
def search(self, data, anns_field, param, limit, expr=None,
|
||||
|
|
|
@ -35,10 +35,12 @@ class ApiPartitionWrapper:
|
|||
|
||||
@property
|
||||
def is_empty(self):
|
||||
self.flush()
|
||||
return self.partition.is_empty if self.partition else None
|
||||
|
||||
@property
|
||||
def num_entities(self):
|
||||
self.flush()
|
||||
return self.partition.num_entities if self.partition else None
|
||||
|
||||
def drop(self, check_task=None, check_items=None, **kwargs):
|
||||
|
@ -73,6 +75,17 @@ class ApiPartitionWrapper:
|
|||
**kwargs).run()
|
||||
return res, check_result
|
||||
|
||||
def flush(self, check_task=None, check_items=None, **kwargs):
|
||||
timeout = kwargs.get("timeout", TIMEOUT)
|
||||
kwargs.update({"timeout": timeout})
|
||||
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, succ = api_request([self.partition.flush], **kwargs)
|
||||
check_result = ResponseChecker(res, func_name, check_task,
|
||||
check_items, is_succ=succ,
|
||||
**kwargs).run()
|
||||
return res, check_result
|
||||
|
||||
def insert(self, data, check_task=None, check_items=None, **kwargs):
|
||||
timeout = kwargs.get("timeout", TIMEOUT)
|
||||
kwargs.update({"timeout": timeout})
|
||||
|
|
|
@ -9,7 +9,7 @@ allure-pytest==2.7.0
|
|||
pytest-print==0.2.1
|
||||
pytest-level==0.1.1
|
||||
pytest-xdist==2.5.0
|
||||
pymilvus==2.1.0.dev103
|
||||
pymilvus==2.2.0.dev6
|
||||
pytest-rerunfailures==9.1.1
|
||||
git+https://github.com/Projectplace/pytest-tags
|
||||
ndg-httpsclient
|
||||
|
|
|
@ -241,8 +241,8 @@ class TestAliasOperation(TestcaseBase):
|
|||
|
||||
# assert insert data
|
||||
pytest.assume(insert_data_flag is True and
|
||||
collection_alias.num_entities == ct.default_nb and
|
||||
collection_w.num_entities == ct.default_nb)
|
||||
collection_w.num_entities == ct.default_nb and
|
||||
collection_alias.num_entities == ct.default_nb)
|
||||
|
||||
# create index by alias
|
||||
default_index = {"index_type": "IVF_FLAT", "params": {"nlist": 128}, "metric_type": "L2"}
|
||||
|
|
|
@ -1381,6 +1381,7 @@ class TestCollectionDataframe(TestcaseBase):
|
|||
res, _ = self.collection_wrap.construct_from_dataframe(cf.gen_unique_str(prefix), df,
|
||||
primary_field=ct.default_int64_field_name, auto_id=False)
|
||||
collection_w = res[0]
|
||||
collection_w.flush()
|
||||
assert collection_w.num_entities == nb
|
||||
mutation_res = res[1]
|
||||
assert mutation_res.primary_keys == df[ct.default_int64_field_name].values.tolist()
|
||||
|
|
|
@ -33,9 +33,9 @@ class TestE2e(TestcaseBase):
|
|||
|
||||
# flush
|
||||
t0 = time.time()
|
||||
num_entities, check_result = collection_w.flush(timeout=180)
|
||||
_, check_result = collection_w.flush(timeout=180)
|
||||
assert check_result
|
||||
assert num_entities == len(data[0]) + entities
|
||||
assert collection_w.num_entities == len(data[0]) + entities
|
||||
tt = time.time() - t0
|
||||
entities = collection_w.num_entities
|
||||
log.info(f"assert flush: {tt}, entities: {entities}")
|
||||
|
|
|
@ -90,7 +90,7 @@ class TestIndexParams(TestcaseBase):
|
|||
ct.err_msg: f"cannot create index on non-existed field: {f_name}"})
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L0)
|
||||
# TODO (reason="pymilvus issue #677", raises=TypeError)
|
||||
@pytest.mark.xfail(reason="pymilvus issue 677")
|
||||
@pytest.mark.parametrize("index_type", ct.get_invalid_strs)
|
||||
def test_index_type_invalid(self, index_type):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue