Create a common module to define the document model.
Import the common document model in the gateway and the executor.
Use self.streamer.stream in the gateway to send request to a specific executor.
The documents (shared document model) returned by the executor cannot be added to a DocList of the same shared document model defined in the executor. The gateway throws the following exception.
DEBUG text_encoder/rep-0@132549 recv DataRequest at /encode [08/03/23 11:00:53]
with id: d624f1fa2e3246499d678973990772e0
INFO: 127.0.0.1:53964 - "POST /index HTTP/1.1" 500 Internal Server Error
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/home/girishc13/Documents/Code/jina-ai/eatsmarter-prototype/venv/lib/python3.10/site-packages/uvicorn/protocols/http/httptools_impl.py", line 426, in run_asgi
result = await app( # type: ignore[func-returns-value]
File "/home/girishc13/Documents/Code/jina-ai/eatsmarter-prototype/venv/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
return await self.app(scope, receive, send)
File "/home/girishc13/Documents/Code/jina-ai/eatsmarter-prototype/venv/lib/python3.10/site-packages/fastapi/applications.py", line 289, in __call__
await super().__call__(scope, receive, send)
File "/home/girishc13/Documents/Code/jina-ai/eatsmarter-prototype/venv/lib/python3.10/site-packages/starlette/applications.py", line 122, in __call__
await self.middleware_stack(scope, receive, send)
File "/home/girishc13/Documents/Code/jina-ai/eatsmarter-prototype/venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 184, in __call__
raise exc
File "/home/girishc13/Documents/Code/jina-ai/eatsmarter-prototype/venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 162, in __call__
await self.app(scope, receive, _send)
File "/home/girishc13/Documents/Code/jina-ai/eatsmarter-prototype/venv/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
raise exc
File "/home/girishc13/Documents/Code/jina-ai/eatsmarter-prototype/venv/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
await self.app(scope, receive, sender)
File "/home/girishc13/Documents/Code/jina-ai/eatsmarter-prototype/venv/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in __call__
raise e
File "/home/girishc13/Documents/Code/jina-ai/eatsmarter-prototype/venv/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in __call__
await self.app(scope, receive, send)
File "/home/girishc13/Documents/Code/jina-ai/eatsmarter-prototype/venv/lib/python3.10/site-packages/starlette/routing.py", line 718, in __call__
await route.handle(scope, receive, send)
File "/home/girishc13/Documents/Code/jina-ai/eatsmarter-prototype/venv/lib/python3.10/site-packages/starlette/routing.py", line 276, in handle
await self.app(scope, receive, send)
File "/home/girishc13/Documents/Code/jina-ai/eatsmarter-prototype/venv/lib/python3.10/site-packages/starlette/routing.py", line 66, in app
response = await func(request)
File "/home/girishc13/Documents/Code/jina-ai/eatsmarter-prototype/venv/lib/python3.10/site-packages/fastapi/routing.py", line 273, in app
raw_response = await run_endpoint_function(
File "/home/girishc13/Documents/Code/jina-ai/eatsmarter-prototype/venv/lib/python3.10/site-packages/fastapi/routing.py", line 190, in run_endpoint_function
return await dependant.call(**values)
File "/home/girishc13/Documents/Code/jina-ai/eatsmarter/gateway/gateway.py", line 74, in index
encoded_docs.extend(docs)
File "/home/girishc13/Documents/Code/jina-ai/eatsmarter-prototype/venv/lib/python3.10/site-packages/docarray/array/doc_list/doc_list.py", line 195, in extend
return super().extend(it)
File "/home/girishc13/Documents/Code/jina-ai/eatsmarter-prototype/venv/lib/python3.10/site-packages/docarray/array/doc_list/doc_list.py", line 158, in _validate_docs
yield self._validate_one_doc(doc)
File "/home/girishc13/Documents/Code/jina-ai/eatsmarter-prototype/venv/lib/python3.10/site-packages/docarray/array/doc_list/doc_list.py", line 165, in _validate_one_doc
raise ValueError(f'{doc} is not a {self.doc_type}')
ValueError: RecipeDoc(id='1234', text='grilled fish', bytes_=None, embedding=None, url=None) is not a <class 'commons.document_models.RecipeDoc'>
Describe the bug
self.streamer.stream
in the gateway to send request to a specific executor.The documents (shared document model) returned by the executor cannot be added to a DocList of the same shared document model defined in the executor. The gateway throws the following exception.
You can find a zip file with the code that can be used to reproduce the error. jina-docarrayv2-ser-de-example.zip
Describe how you solve it
Environment
Screenshots