Skip to content

Commit dbd278f

Browse files
author
Joan Martinez
committed
fix: set direct docs
1 parent b28c633 commit dbd278f

File tree

4 files changed

+21
-11
lines changed

4 files changed

+21
-11
lines changed

jina/clients/base/http.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def _result_handler(result):
219219

220220
resp = DataRequest(r_str)
221221
if da is not None:
222-
resp.data.docs = da
222+
resp.direct_docs = da
223223

224224
callback_exec(
225225
response=resp,

jina/clients/mixin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ async def _get_results(*args, **kwargs):
414414
if return_responses:
415415
result.append(resp)
416416
else:
417-
result.extend(resp.data.docs)
417+
result.extend(resp.docs)
418418
if return_results:
419419
if not return_responses and is_singleton and len(result) == 1:
420420
return result[0]
@@ -538,7 +538,7 @@ async def post(
538538
is_singleton = True
539539
result.document_array_cls = DocList[return_type]
540540
if not return_responses:
541-
ret_docs = result.data.docs
541+
ret_docs = result.docs
542542
if is_singleton and len(ret_docs) == 1:
543543
yield ret_docs[0]
544544
else:

jina/serve/runtimes/worker/http_fastapi_app.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,16 @@ async def post(body: input_model, response: Response):
9999
data = body.data
100100
if isinstance(data, list):
101101
if not docarray_v2:
102-
req.data.docs = DocumentArray.from_pydantic_model(data)
102+
req.direct_docs = DocumentArray.from_pydantic_model(data)
103103
else:
104104
req.document_array_cls = DocList[input_doc_model]
105-
req.data.docs = DocList[input_doc_list_model](data)
105+
req.direct_docs = DocList[input_doc_list_model](data)
106106
else:
107107
if not docarray_v2:
108-
req.data.docs = DocumentArray([Document.from_pydantic_model(data)])
108+
req.direct_docs = DocumentArray([Document.from_pydantic_model(data)])
109109
else:
110110
req.document_array_cls = DocList[input_doc_model]
111-
req.data.docs = DocList[input_doc_list_model]([data])
111+
req.direct_docs = DocList[input_doc_list_model]([data])
112112
if body.header is None:
113113
req.header.request_id = req.docs[0].id
114114

@@ -152,10 +152,10 @@ async def streaming_get(request: Request = None, body: input_doc_model = None):
152152
req = DataRequest()
153153
req.header.exec_endpoint = endpoint_path
154154
if not docarray_v2:
155-
req.data.docs = DocumentArray([body])
155+
req.direct_docs = DocumentArray([body])
156156
else:
157157
req.document_array_cls = DocList[input_doc_model]
158-
req.data.docs = DocList[input_doc_model]([body])
158+
req.direct_docs = DocList[input_doc_model]([body])
159159
event_generator = _gen_dict_documents(await caller(req))
160160
return EventSourceResponse(event_generator)
161161

jina/types/request/data.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ def __init__(
114114
self._pb_body = None
115115
self._document_array_cls = DocumentArray
116116
self._data = None
117+
# to be used to bypass proto extra transforms
118+
self.direct_docs = None
117119

118120
try:
119121
if isinstance(request, jina_pb2.DataRequestProto):
@@ -275,7 +277,10 @@ def docs(self) -> 'DocumentArray':
275277
"""Get the :class: `DocumentArray` with sequence `data.docs` as content.
276278
277279
.. # noqa: DAR201"""
278-
return self.data.docs
280+
if self.direct_docs is not None:
281+
return self.direct_docs
282+
else:
283+
return self.data.docs
279284

280285
@property
281286
def data(self) -> 'DataRequest._DataContent':
@@ -441,6 +446,8 @@ def __init__(
441446
self._document_cls = Document
442447
self.buffer = None
443448
self._data = None
449+
# to be used to bypass proto extra transforms
450+
self.direct_doc = None
444451

445452
try:
446453
if isinstance(request, jina_pb2.SingleDocumentRequestProto):
@@ -606,7 +613,10 @@ def doc(self) -> 'Document':
606613
"""Get the :class: `DocumentArray` with sequence `data.docs` as content.
607614
608615
.. # noqa: DAR201"""
609-
return self.data.doc
616+
if self.direct_doc is not None:
617+
return self.direct_doc
618+
else:
619+
return self.data.doc
610620

611621
@property
612622
def data(self) -> 'SingleDocumentRequest._DataContent':

0 commit comments

Comments
 (0)