Skip to content

Commit

Permalink
Merge pull request milvus-io#44 from XuanYang-cn/master
Browse files Browse the repository at this point in the history
[ISSUE-milvus-io#41] fix prepare after prepare will raise exception bug
  • Loading branch information
JinHai-CN committed Jul 4, 2019
2 parents 38759cd + a99d9e6 commit af74986
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 12 deletions.
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
### Bug
---

- \#12 ISSUE
- IndexType change
- fix param of search_vector_in_files ranges
Expand All @@ -15,15 +17,16 @@
- Optimize some dataclass and add utils.py module
- Fix type of tile_ids in search_in_files api transfer bug
- Fix Prepare after Prepare will raise ParamError bug
- \#43 ISSUE: fix prepare after prepare will raise exceptions bug
### Improvement

---
- \#10 Update examples
- \#14 Update example
- \#28 Update README with newest sdk
- \#33 Update thrift has_table API
- \#38 Update thrift score to distance
### New Feature

---
- \#3
- transport protocol configurable by settings
- add_vector support non-binary array inputs
Expand All @@ -49,7 +52,7 @@
- support search by range
- fix server_status return None bug
### Task

---
- \#1 Build Repository

- \#2 Add CHANGELOG.md and LICENSE, update setup.py
2 changes: 1 addition & 1 deletion milvus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

__all__ = ['Milvus', 'Prepare', 'Status', 'IndexType', '__version__']

__version__ = '0.1.15'
__version__ = '0.1.16'

10 changes: 8 additions & 2 deletions milvus/client/Client.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

LOGGER = logging.getLogger(__name__)

__version__ = '0.1.15'
__version__ = '0.1.16'
__NAME__ = 'pymilvus'


Expand Down Expand Up @@ -70,6 +70,9 @@ def table_schema(cls, param):
type(dict), type(param)
))

else:
return param

return ttypes.TableSchema(table_name=temp.table_name,
dimension=temp.dimension,
index_type=temp.index_type,
Expand Down Expand Up @@ -111,7 +114,10 @@ def ranges(cls, ranges):
"""
res = []
for _range in ranges:
res.append(Prepare.range(_range[0], _range[1]))
if not isinstance(_range, ttypes.Range):
res.append(Prepare.range(_range[0], _range[1]))
else:
res.append(_range)
return res

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setuptools.setup(
name="pymilvus",
version="0.1.15",
version="0.1.16",
description="Python Sdk for Milvus",
long_description=README,
long_description_content_type='text/markdown',
Expand Down
30 changes: 25 additions & 5 deletions tests/TestClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def test_create_table(self, CreateTable, client):
res = client.create_table(param)

param = table_schema_factory()
param['table_name'] = 1234456
param['table_name'] = 1234456
res = client.create_table(param)
assert res.OK()

Expand Down Expand Up @@ -289,7 +289,7 @@ def test_search_vector(self, SearchVector, client):
assert res.OK()
assert isinstance(results, (list, TopKQueryResult))

@mock.patch.object(MilvusService, 'SearchVector')
@mock.patch.object(MilvusService.Client, 'SearchVector')
def test_search_vector_with_range(self, SearchVector, client):
SearchVector.return_value = [ttypes.TopKQueryResult([ttypes.QueryResult(111, 111)])]
param = {
Expand Down Expand Up @@ -336,7 +336,7 @@ def test_false_vector(self, client):
with pytest.raises(ParamError):
res, results = client.search_vectors(**param)

@mock.patch.object(MilvusService, 'SearchVectorInFiles')
@mock.patch.object(MilvusService.Client, 'SearchVectorInFiles')
def test_search_in_files(self, SearchVectorInFiles, client):
SearchVectorInFiles.return_value = [ttypes.TopKQueryResult([ttypes.QueryResult(111, 111)])]
param = {
Expand Down Expand Up @@ -432,13 +432,26 @@ def test_table_schema(self):
res = Prepare.table_schema(param)
assert isinstance(res, ttypes.TableSchema)

def test_double_schema(self):
param = {
'table_name': fake.table_name(),
'dimension': random.randint(0, 999),
'index_type': IndexType.FLAT,
'store_raw_vector': False
}
res = Prepare.table_schema(param)
a = Prepare.table_schema(res)
assert a == res
assert isinstance(a, ttypes.TableSchema)
assert isinstance(res, ttypes.TableSchema)

def test_range(self):
param = {'start_date':'2019-02-02','end_date':'2019-02-02'}
param = {'start_date': '2019-02-02', 'end_date': '2019-02-02'}
res = Prepare.range(**param)
assert isinstance(res, ttypes.Range)

def test_ranges(self):
param = [('2019-02-02','2019-02-02')]
param = [('2019-02-02', '2019-02-02')]
res = Prepare.ranges(param)
assert isinstance(res, list)
assert isinstance(res[0], ttypes.Range)
Expand All @@ -447,6 +460,13 @@ def test_ranges(self):
with pytest.raises(ParamError):
res = Prepare.ranges(param)

def test_repeating_range(self):
param = [('2019-02-02', '2019-02-02')]
res = Prepare.ranges(param)
a = Prepare.ranges(res)
assert isinstance(a[0], ttypes.Range)
assert a == res

def test_row_record(self):
vec = [random.random() + random.randint(0, 9) for _ in range(256)]
res = Prepare.row_record(vec)
Expand Down

0 comments on commit af74986

Please sign in to comment.