jina.types.request.data module#

class jina.types.request.data.DataRequest(request=None)[source]#

Bases: jina.types.request.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

Return type

bool

Returns

True if the proto was deserialized before

property proto: jina_pb2.DataRequestProto#

Cast self to a jina_pb2.DataRequestProto. Laziness will be broken and serialization will be recomputed when calling SerializeToString(). :rtype: DataRequestProto :return: 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: docarray.array.document.DocumentArray#

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

Return type

DocumentArray

data#

The decorator to cache property of a class.

property parameters: Dict#

Return the parameters field of this DataRequest as a Python dict :rtype: Dict :return: a Python dict view of the parameters.

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

Returns the response of this request.

Returns

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

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 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: jina.types.request.data.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: docarray.array.document.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

Return type

bool

Returns

True if the proto was deserialized before

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: jina_pb2.DataRequestProto#

Cast self to a jina_pb2.DataRequestProto. Laziness will be broken and serialization will be recomputed when calling SerializeToString(). :rtype: DataRequestProto :return: protobuf instance

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