-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix subclass with DocList (#6138)
Signed-off-by: Joan Martinez <[email protected]>
- Loading branch information
Showing
6 changed files
with
68 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
30 changes: 30 additions & 0 deletions
30
tests/integration/docarray_v2/issues/github_6137/test_issue.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from docarray import DocList, BaseDoc | ||
from docarray.documents.text import TextDoc | ||
from jina import Executor, requests, Flow | ||
|
||
|
||
def test_issue(): | ||
class QuoteFile(BaseDoc): | ||
quote_file_id: int = None | ||
texts: DocList[TextDoc] = None | ||
|
||
class SearchResult(BaseDoc): | ||
results: DocList[QuoteFile] = None | ||
|
||
class InitialExecutor(Executor): | ||
|
||
@requests(on='/search') | ||
async def search(self, docs: DocList[SearchResult], **kwargs) -> DocList[SearchResult]: | ||
return docs | ||
|
||
f = ( | ||
Flow(protocol='http') | ||
.add(name='initial', uses=InitialExecutor) | ||
) | ||
|
||
with f: | ||
resp = f.post(on='/search', inputs=DocList[SearchResult]([SearchResult(results=DocList[QuoteFile]( | ||
[QuoteFile(quote_file_id=999, texts=DocList[TextDoc]([TextDoc(text='hey here')]))]))]), | ||
return_type=DocList[SearchResult]) | ||
assert resp[0].results[0].quote_file_id == 999 | ||
assert resp[0].results[0].texts[0].text == 'hey here' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters