jina.types.request

class jina.types.request.Request(request=None, envelope=None, copy=False)[source]

Bases: object

Request is one of the primitive data type in Jina.

It offers a Pythonic interface to allow users access and manipulate jina.jina_pb2.RequestProto object without working with Protobuf itself.

A container for serialized jina_pb2.RequestProto that only triggers deserialization and decompression when receives the first read access to its member.

It overrides __getattr__() to provide the same get/set interface as an jina_pb2.RequestProto object.

is_used = None

Return True when request has been r/w at least once

property body
property request_type

Return the request body type, when not set yet, return None

Return type

Optional[str]

property docs
Return type

DocumentSet

property groundtruths
Return type

DocumentSet

property as_pb_object
Cast self to a jina_pb2.RequestProto. This will trigger

is_used. Laziness will be broken and serialization will be recomputed when calling SerializeToString().

Return type

RequestProto

SerializeToString()[source]
property queryset
Return type

QueryLangSet

property command
Return type

str

to_json()[source]

Return the object in JSON string

Return type

str

to_response()[source]

Return a weak reference of this object but as Response object. It gives a more consistent semantics on the client.

Return type

Response

class jina.types.request.Response(request=None, envelope=None, copy=False)[source]

Bases: jina.types.request.Request

Response is the Request object returns from the flow. Right now it shares the same representation as Request. At 0.8.12, Response is a simple alias. But it does give a more consistent semantic on the client API: send a Request and receive a Response.