Skip to content

fix(find): fix misleading signature of _find_by_text#495

Merged
hanxiao merged 1 commit intomainfrom
fix-misleading-signature
Aug 22, 2022
Merged

fix(find): fix misleading signature of _find_by_text#495
hanxiao merged 1 commit intomainfrom
fix-misleading-signature

Conversation

@hanxiao
Copy link
Copy Markdown
Member

@hanxiao hanxiao commented Aug 22, 2022

from docarray import Document, DocumentArray

d = Document(uri='https://www.gutenberg.org/files/1342/1342-0.txt').load_uri_to_text()
da = DocumentArray(Document(text=s.strip()) for s in d.text.split('\n') if s.strip())
print(da.find('hello'))

Before:

Traceback (most recent call last):
  File "/Users/hanxiao/Documents/jina/toy43.py", line 5, in <module>
    print(da.find('hello'))
  File "/Users/hanxiao/Documents/docarray/docarray/array/mixins/find.py", line 168, in find
    result = self._find_by_text(query, index=index, limit=limit, **kwargs)
TypeError: _find_by_text() got an unexpected keyword argument 'limit'

After:

Traceback (most recent call last):
  File "/Users/hanxiao/Documents/jina/toy43.py", line 5, in <module>
    print(da.find('hello'))
  File "/Users/hanxiao/Documents/docarray/docarray/array/mixins/find.py", line 168, in find
    result = self._find_by_text(query, index=index, limit=limit, **kwargs)
  File "/Users/hanxiao/Documents/docarray/docarray/array/mixins/find.py", line 303, in _find_by_text
    raise NotImplementedError(f'Search by text is not supported with this backend {self.__class__.__name__}')
NotImplementedError: Search by text is not supported with this backend DocumentArrayInMemory

Process finished with exit code 1

@codecov
Copy link
Copy Markdown

codecov bot commented Aug 22, 2022

Codecov Report

Merging #495 (e62c771) into main (c936b18) will decrease coverage by 0.05%.
The diff coverage is 30.00%.

@@            Coverage Diff             @@
##             main     #495      +/-   ##
==========================================
- Coverage   86.51%   86.46%   -0.06%     
==========================================
  Files         134      134              
  Lines        6698     6702       +4     
==========================================
  Hits         5795     5795              
- Misses        903      907       +4     
Flag Coverage Δ
docarray 86.46% <30.00%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
docarray/document/mixins/video.py 53.12% <14.28%> (-3.55%) ⬇️
docarray/array/mixins/find.py 87.62% <50.00%> (ø)
docarray/__init__.py 75.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@hanxiao hanxiao merged commit 69a976f into main Aug 22, 2022
@hanxiao hanxiao deleted the fix-misleading-signature branch August 22, 2022 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant