Skip to content

Commit

Permalink
fix: wrong input exception
Browse files Browse the repository at this point in the history
  • Loading branch information
ZiniuYu committed Sep 16, 2022
1 parent f4ee3a2 commit 5e030e4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
8 changes: 4 additions & 4 deletions client/clip_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,12 +443,8 @@ def _prepare_rank_doc(d: 'Document', _source: str = 'matches'):
def _reset_rank_doc(d: 'Document', _source: str = 'matches'):
_get = lambda d: getattr(d, _source)

print(123123)
if d.tags.pop('__loaded_by_CAS__', False):
print(111)
d.pop('blob')
else:
print(222)

for c in _get(d):
if c.tags.pop('__loaded_by_CAS__', False):
Expand All @@ -466,6 +462,8 @@ def rank(
:param docs: the input Documents
:return: the ranked Documents in a DocumentArray.
"""
if isinstance(docs, str):
raise TypeError(f'Content must be an Iterable of [Document]')
if hasattr(docs, '__len__') and len(docs) == 0:
return DocumentArray() if isinstance(docs, DocumentArray) else []

Expand Down Expand Up @@ -497,6 +495,8 @@ async def arank(
) -> 'DocumentArray':
from rich import filesize

if isinstance(docs, str):
raise TypeError(f'Content must be an Iterable of [Document]')
if hasattr(docs, '__len__') and len(docs) == 0:
return DocumentArray() if isinstance(docs, DocumentArray) else []

Expand Down
16 changes: 1 addition & 15 deletions tests/test_ranker.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,6 @@ def test_docarray_inputs(make_flow, inputs):
Document(text='goodbye, world'),
],
),
Document(
uri='https://docarray.jina.ai/_static/favicon.png',
matches=[
Document(text='hello, world'),
Document(text='goodbye, world'),
],
),
],
DocumentArray(
[
Expand All @@ -176,13 +169,6 @@ def test_docarray_inputs(make_flow, inputs):
Document(text='goodbye, world'),
],
),
Document(
uri='https://docarray.jina.ai/_static/favicon.png',
matches=[
Document(text='hello, world'),
Document(text='goodbye, world'),
],
),
]
),
lambda: (
Expand All @@ -193,7 +179,7 @@ def test_docarray_inputs(make_flow, inputs):
Document(text='goodbye, world'),
],
)
for _ in range(10)
for _ in range(1)
),
DocumentArray(
[
Expand Down

0 comments on commit 5e030e4

Please sign in to comment.