jina.types.request.data module#
- class jina.types.request.data.DataRequest(request=None)[source]#
Bases:
Request
Represents a DataRequest used for exchanging
docarray.DocumentArray
with and within a Flow.When calling
post()
on any Jina client, the provided inputdocarray.DocumentArray
will be converted to aDataRequest
before being sent to a Flow.- property document_array_cls: Type[DocumentArray]#
Get the DocumentArray class to be used for deserialization.
- Return type:
Type
[DocumentArray
]
- property is_decompressed: bool#
Checks if the underlying proto object was already deserialized into a
jina.proto.jina_pb2.DataRequestProto
orjina.proto.jina_pb2.DataRequestProtoWoData
. This does not necessarily mean that the data (docs) inside the request is also decompressed.- return:
True if the proto was deserialized before
- Return type:
bool
- property is_decompressed_with_data: bool#
- Checks if the underlying proto object was already deserialized into a
jina.proto.jina_pb2.DataRequestProto
. In this case the full proto is decompressed, including the data (docs). - return:
True if the proto was deserialized before, including the data (docs)
- Return type:
bool
- Checks if the underlying proto object was already deserialized into a
- property is_decompressed_wo_data: bool#
Checks if the underlying proto object was already deserialized into a
jina.proto.jina_pb2.DataRequestProtoWoData
. It means that the proto is loaded without the data ( docs ).- Return type:
bool
- Returns:
True if the proto was deserialized before into a DataRequest without docs
- property proto_wo_data: Union[DataRequestProtoWoData, DataRequestProto]#
Transform the current buffer to a
jina_pb2.DataRequestProtoWoData
unless the full proto has already been initialized or . Laziness will be broken and serialization will be recomputed when callingSerializeToString()
. :rtype:Union
[DataRequestProtoWoData
,DataRequestProto
] :return: protobuf instance containing parameters
- property proto: Union[DataRequestProto, DataRequestProtoWoData]#
Cast
self
to ajina_pb2.DataRequestProto
or ajina_pb2.DataRequestProto
. Laziness will be broken and serialization will be recomputed when calling. it returns the underlying proto if it already exists (even if he is loaded without data) or creates a new one.SerializeToString()
. :rtype:Union
[DataRequestProto
,DataRequestProtoWoData
] :return: DataRequestProto protobuf instance
- property proto_with_data: DataRequestProto#
Cast
self
to ajina_pb2.DataRequestProto
. Laziness will be broken and serialization will be recomputed when calling.SerializeToString()
. :rtype:DataRequestProto
:return: DataRequestProto protobuf instance
- to_dict()[source]#
Return the object in Python dictionary.
Note
Array like object such as
numpy.ndarray
(i.e. anything described asjina_pb2.NdArrayProto
) will be converted to Python list.- Return type:
Dict
- Returns:
dict representation of the object
- property docs: DocumentArray#
Get the :class: DocumentArray with sequence data.docs as content.
- Return type:
DocumentArray
- property data: _DataContent#
Get the data contained in this data request
- Return type:
_DataContent
- Returns:
the data content as an instance of _DataContent wrapping docs
- property parameters: Dict#
Return the parameters field of this DataRequest as a Python dict
- Return type:
Dict
- Returns:
a Python dict view of the parameters.
- property response#
Returns the response of this request.
- Returns:
the response of this request (self) as an instance of Response
- CopyFrom(other)#
Copy the content of target
- Parameters:
other (
TypeVar
(T
)) – the document to copy from- Return type:
None
- MergeFrom(other)#
Merge the content of target
- Parameters:
other (
TypeVar
(T
)) – the document to merge from- Return type:
None
- add_exception(ex=None, executor=None)#
Add exception to the last route in the envelope :type ex:
Optional
[Exception
] :param ex: Exception to be added :type executor:Optional
[BaseExecutor
] :param executor: Executor related to the exception- Return type:
None
- binary_str(**kwargs)#
- clear()#
Remove all values from all fields of this Document.
- Return type:
None
- dict(**kwargs)#
- json(**kwargs)#
- property nbytes: int#
Return total bytes consumed by protobuf.
- Return type:
int
- Returns:
number of bytes
- pop(*fields)#
Remove the values from the given fields of this Document.
- Parameters:
fields – field names
- Return type:
None
- property status#
Returns the status from the header field
- Returns:
the status object of this request
- to_bytes()#
Return the serialized the message to a string.
For more Pythonic code, please use
bytes(...)
.- Return type:
bytes
- Returns:
binary string representation of the object
- to_json()#
Return the object in JSON string
- Return type:
str
- Returns:
JSON string of the object
- property last_executor#
Returns the name of the last Executor that has processed this Request
- Returns:
the name of the last Executor that processed this Request
- add_executor(executor_name)[source]#
Adds Executor the the request routes
- Parameters:
executor_name (
str
) – name of the Executor processing the Request to be added to the routes
- property routes#
Returns the routes from the request
- Returns:
the routes object of this request
- property request_id#
Returns the request_id from the header field
- Returns:
the request_id object of this request
- class jina.types.request.data.Response(request=None)[source]#
Bases:
DataRequest
Response is the
Request
object returned by the flow.At the moment it is an alias for
Request
, and therefore shares an identical representation. Currently, its sole purpose is to give a more consistent semantic on the client API: send aDataRequest
and receive aResponse
.- CopyFrom(other)#
Copy the content of target
- Parameters:
other (
TypeVar
(T
)) – the document to copy from- Return type:
None
- MergeFrom(other)#
Merge the content of target
- Parameters:
other (
TypeVar
(T
)) – the document to merge from- Return type:
None
- add_exception(ex=None, executor=None)#
Add exception to the last route in the envelope :type ex:
Optional
[Exception
] :param ex: Exception to be added :type executor:Optional
[BaseExecutor
] :param executor: Executor related to the exception- Return type:
None
- add_executor(executor_name)#
Adds Executor the the request routes
- Parameters:
executor_name (
str
) – name of the Executor processing the Request to be added to the routes
- binary_str(**kwargs)#
- clear()#
Remove all values from all fields of this Document.
- Return type:
None
- property data: _DataContent#
Get the data contained in this data request
- Return type:
_DataContent
- Returns:
the data content as an instance of _DataContent wrapping docs
- dict(**kwargs)#
- property docs: DocumentArray#
Get the :class: DocumentArray with sequence data.docs as content.
- Return type:
DocumentArray
- property document_array_cls: Type[DocumentArray]#
Get the DocumentArray class to be used for deserialization.
- Return type:
Type
[DocumentArray
]
- classmethod from_proto(request)#
Creates a new DataRequest object from a given
DataRequestProto
object. :type request:DataRequestProto
:param request: the to-be-copied data request :return: the new message object
- property is_decompressed: bool#
Checks if the underlying proto object was already deserialized into a
jina.proto.jina_pb2.DataRequestProto
orjina.proto.jina_pb2.DataRequestProtoWoData
. This does not necessarily mean that the data (docs) inside the request is also decompressed.- return:
True if the proto was deserialized before
- Return type:
bool
- property is_decompressed_with_data: bool#
- Checks if the underlying proto object was already deserialized into a
jina.proto.jina_pb2.DataRequestProto
. In this case the full proto is decompressed, including the data (docs). - return:
True if the proto was deserialized before, including the data (docs)
- Return type:
bool
- Checks if the underlying proto object was already deserialized into a
- property is_decompressed_wo_data: bool#
Checks if the underlying proto object was already deserialized into a
jina.proto.jina_pb2.DataRequestProtoWoData
. It means that the proto is loaded without the data ( docs ).- Return type:
bool
- Returns:
True if the proto was deserialized before into a DataRequest without docs
- json(**kwargs)#
- property last_executor#
Returns the name of the last Executor that has processed this Request
- Returns:
the name of the last Executor that processed this Request
- property nbytes: int#
Return total bytes consumed by protobuf.
- Return type:
int
- Returns:
number of bytes
- property parameters: Dict#
Return the parameters field of this DataRequest as a Python dict
- Return type:
Dict
- Returns:
a Python dict view of the parameters.
- pop(*fields)#
Remove the values from the given fields of this Document.
- Parameters:
fields – field names
- Return type:
None
- property proto: Union[DataRequestProto, DataRequestProtoWoData]#
Cast
self
to ajina_pb2.DataRequestProto
or ajina_pb2.DataRequestProto
. Laziness will be broken and serialization will be recomputed when calling. it returns the underlying proto if it already exists (even if he is loaded without data) or creates a new one.SerializeToString()
. :rtype:Union
[DataRequestProto
,DataRequestProtoWoData
] :return: DataRequestProto protobuf instance
- property proto_with_data: DataRequestProto#
Cast
self
to ajina_pb2.DataRequestProto
. Laziness will be broken and serialization will be recomputed when calling.SerializeToString()
. :rtype:DataRequestProto
:return: DataRequestProto protobuf instance
- property proto_wo_data: Union[DataRequestProtoWoData, DataRequestProto]#
Transform the current buffer to a
jina_pb2.DataRequestProtoWoData
unless the full proto has already been initialized or . Laziness will be broken and serialization will be recomputed when callingSerializeToString()
. :rtype:Union
[DataRequestProtoWoData
,DataRequestProto
] :return: protobuf instance containing parameters
- property request_id#
Returns the request_id from the header field
- Returns:
the request_id object of this request
- property response#
Returns the response of this request.
- Returns:
the response of this request (self) as an instance of Response
- property routes#
Returns the routes from the request
- Returns:
the routes object of this request
- property status#
Returns the status from the header field
- Returns:
the status object of this request
- to_bytes()#
Return the serialized the message to a string.
For more Pythonic code, please use
bytes(...)
.- Return type:
bytes
- Returns:
binary string representation of the object
- to_dict()#
Return the object in Python dictionary.
Note
Array like object such as
numpy.ndarray
(i.e. anything described asjina_pb2.NdArrayProto
) will be converted to Python list.- Return type:
Dict
- Returns:
dict representation of the object
- to_json()#
Return the object in JSON string
- Return type:
str
- Returns:
JSON string of the object