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 input docarray.DocumentArray will be converted to a DataRequest before being sent to a Flow.

property is_decompressed: bool#

Checks if the underlying proto object was already deserialized into a jina.proto.jina_pb2.DataRequestProto or jina.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

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 calling SerializeToString(). :rtype: Union[DataRequestProtoWoData, DataRequestProto] :return: protobuf instance containing parameters

property proto: Union[DataRequestProto, DataRequestProtoWoData]#

Cast self to a jina_pb2.DataRequestProto or a jina_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 a jina_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 as jina_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

data#

The decorator to cache property of a class.

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

property parameters: Dict#

Return the parameters field of this DataRequest as a Python dict :rtype: Dict :return: 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

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 response#

Returns the response of this request.

Returns:

the response of this request (self) as an instance of Response

property status#

Returns the status from the header field

Returns:

the status object of this request

property request_id#

Returns the request_id from the header field

Returns:

the request_id object of this request

classmethod from_proto(request)[source]#

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

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 a DataRequest and receive a 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)#
property docs: DocumentArray#

Get the :class: DocumentArray with sequence data.docs as content.

Return 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 or jina.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

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 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 :rtype: Dict :return: 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 a jina_pb2.DataRequestProto or a jina_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 a jina_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 calling SerializeToString(). :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 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 as jina_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