jina.serve.runtimes.gateway.http.models module#

class jina.serve.runtimes.gateway.http.models.CustomConfig[source]#

Bases: BaseConfig

Pydantic config for Camel case and enum handling

use_enum_values = True#
allow_population_by_field_name = True#
alias_generator = None#
allow_inf_nan = True#
allow_mutation = True#
anystr_lower = False#
anystr_strip_whitespace = False#
anystr_upper = False#
arbitrary_types_allowed = False#
copy_on_model_validation = 'shallow'#
error_msg_templates = {}#
extra = 'ignore'#
fields = {'envs': {'alias': 'envs', 'alias_priority': 2}, 'jina': {'alias': 'jina', 'alias_priority': 2}}#
frozen = False#
classmethod get_field_info(name)#

Get properties of FieldInfo from the fields property of the config class.

Return type:

Dict[str, Any]

getter_dict#

alias of GetterDict

json_dumps(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, default=None, sort_keys=False, **kw)#

Serialize obj to a JSON formatted str.

If skipkeys is true then dict keys that are not basic types (str, int, float, bool, None) will be skipped instead of raising a TypeError.

If ensure_ascii is false, then the return value can contain non-ASCII characters if they appear in strings contained in obj. Otherwise, all such characters are escaped in JSON strings.

If check_circular is false, then the circular reference check for container types will be skipped and a circular reference will result in an OverflowError (or worse).

If allow_nan is false, then it will be a ValueError to serialize out of range float values (nan, inf, -inf) in strict compliance of the JSON specification, instead of using the JavaScript equivalents (NaN, Infinity, -Infinity).

If indent is a non-negative integer, then JSON array elements and object members will be pretty-printed with that indent level. An indent level of 0 will only insert newlines. None is the most compact representation.

If specified, separators should be an (item_separator, key_separator) tuple. The default is (', ', ': ') if indent is None and (',', ': ') otherwise. To get the most compact JSON representation, you should specify (',', ':') to eliminate whitespace.

default(obj) is a function that should return a serializable version of obj or raise TypeError. The default simply raises TypeError.

If sort_keys is true (default: False), then the output of dictionaries will be sorted by key.

To use a custom JSONEncoder subclass (e.g. one that overrides the .default() method to serialize additional types), specify it with the cls kwarg; otherwise JSONEncoder is used.

json_encoders = {}#
json_loads(*, encoding=None, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)#

Deserialize s (a str, bytes or bytearray instance containing a JSON document) to a Python object.

object_hook is an optional function that will be called with the result of any object literal decode (a dict). The return value of object_hook will be used instead of the dict. This feature can be used to implement custom decoders (e.g. JSON-RPC class hinting).

object_pairs_hook is an optional function that will be called with the result of any object literal decoded with an ordered list of pairs. The return value of object_pairs_hook will be used instead of the dict. This feature can be used to implement custom decoders. If object_hook is also defined, the object_pairs_hook takes priority.

parse_float, if specified, will be called with the string of every JSON float to be decoded. By default this is equivalent to float(num_str). This can be used to use another datatype or parser for JSON floats (e.g. decimal.Decimal).

parse_int, if specified, will be called with the string of every JSON int to be decoded. By default this is equivalent to int(num_str). This can be used to use another datatype or parser for JSON integers (e.g. float).

parse_constant, if specified, will be called with one of the following strings: -Infinity, Infinity, NaN. This can be used to raise an exception if invalid JSON numbers are encountered.

To use a custom JSONDecoder subclass, specify it with the cls kwarg; otherwise JSONDecoder is used.

The encoding argument is ignored and deprecated.

keep_untouched = ()#
max_anystr_length = None#
min_anystr_length = 0#
orm_mode = False#
post_init_call = 'before_validation'#
classmethod prepare_field(field)#

Optional hook to check or modify fields during model creation.

Return type:

None

schema_extra = {}#
smart_union = False#
title = None#
underscore_attrs_are_private = False#
validate_all = False#
validate_assignment = False#
jina.serve.runtimes.gateway.http.models.protobuf_to_pydantic_model(protobuf_model)[source]#

Converts Protobuf messages to Pydantic model for jsonschema creation/validattion

..note:: Model gets assigned in the global Namespace :data:PROTO_TO_PYDANTIC_MODELS

Parameters:

protobuf_model (Union[Descriptor, GeneratedProtocolMessageType]) – message from jina.proto file

Return type:

BaseModel

Returns:

Pydantic model

class jina.serve.runtimes.gateway.http.models.JinaHealthModel(**data)[source]#

Bases: BaseModel

Pydantic BaseModel for Jina health check, used as the response model in REST app.

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

Config#

alias of BaseConfig

classmethod construct(_fields_set=None, **values)#

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values

Return type:

Model

copy(*, include=None, exclude=None, update=None, deep=False)#

Duplicate a model, optionally choose which fields to include, exclude and change.

Parameters:
  • include (Union[AbstractSetIntStr, MappingIntStrAny, None]) – fields to include in new model

  • exclude (Union[AbstractSetIntStr, MappingIntStrAny, None]) – fields to exclude from new model, as with values this takes precedence over include

  • update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep (bool) – set to True to make a deep copy of the model

Return type:

Model

Returns:

new model instance

dict(*, include=None, exclude=None, by_alias=False, skip_defaults=None, exclude_unset=False, exclude_defaults=False, exclude_none=False)#

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

Return type:

DictStrAny

classmethod from_orm(obj)#
Return type:

Model

json(*, include=None, exclude=None, by_alias=False, skip_defaults=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, encoder=None, models_as_dict=True, **dumps_kwargs)#

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

Return type:

unicode

classmethod parse_file(path, *, content_type=None, encoding='utf8', proto=None, allow_pickle=False)#
Return type:

Model

classmethod parse_obj(obj)#
Return type:

Model

classmethod parse_raw(b, *, content_type=None, encoding='utf8', proto=None, allow_pickle=False)#
Return type:

Model

classmethod schema(by_alias=True, ref_template='#/definitions/{model}')#
Return type:

DictStrAny

classmethod schema_json(*, by_alias=True, ref_template='#/definitions/{model}', **dumps_kwargs)#
Return type:

unicode

classmethod update_forward_refs(**localns)#

Try to update ForwardRefs on fields based on this Model, globalns and localns.

Return type:

None

classmethod validate(value)#
Return type:

Model

class jina.serve.runtimes.gateway.http.models.JinaInfoModel(**data)[source]#

Bases: BaseModel

Pydantic BaseModel for Jina status, used as the response model in REST app.

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

jina: Dict#
envs: Dict#
class Config[source]#

Bases: object

alias_generator()#
Return type:

str

allow_population_by_field_name = True#
classmethod construct(_fields_set=None, **values)#

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values

Return type:

Model

copy(*, include=None, exclude=None, update=None, deep=False)#

Duplicate a model, optionally choose which fields to include, exclude and change.

Parameters:
  • include (Union[AbstractSetIntStr, MappingIntStrAny, None]) – fields to include in new model

  • exclude (Union[AbstractSetIntStr, MappingIntStrAny, None]) – fields to exclude from new model, as with values this takes precedence over include

  • update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep (bool) – set to True to make a deep copy of the model

Return type:

Model

Returns:

new model instance

dict(*, include=None, exclude=None, by_alias=False, skip_defaults=None, exclude_unset=False, exclude_defaults=False, exclude_none=False)#

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

Return type:

DictStrAny

classmethod from_orm(obj)#
Return type:

Model

json(*, include=None, exclude=None, by_alias=False, skip_defaults=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, encoder=None, models_as_dict=True, **dumps_kwargs)#

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

Return type:

unicode

classmethod parse_file(path, *, content_type=None, encoding='utf8', proto=None, allow_pickle=False)#
Return type:

Model

classmethod parse_obj(obj)#
Return type:

Model

classmethod parse_raw(b, *, content_type=None, encoding='utf8', proto=None, allow_pickle=False)#
Return type:

Model

classmethod schema(by_alias=True, ref_template='#/definitions/{model}')#
Return type:

DictStrAny

classmethod schema_json(*, by_alias=True, ref_template='#/definitions/{model}', **dumps_kwargs)#
Return type:

unicode

classmethod update_forward_refs(**localns)#

Try to update ForwardRefs on fields based on this Model, globalns and localns.

Return type:

None

classmethod validate(value)#
Return type:

Model

class jina.serve.runtimes.gateway.http.models.JinaRequestModel(**data)[source]#

Bases: BaseModel

Jina HTTP request model.

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

data: Optional[Union[List[PydanticDocument], Dict[str, List[PydanticDocument]]]]#
target_executor: Optional[str]#
parameters: Optional[Dict]#
class Config[source]#

Bases: object

alias_generator()#
Return type:

str

allow_population_by_field_name = True#
classmethod construct(_fields_set=None, **values)#

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values

Return type:

Model

copy(*, include=None, exclude=None, update=None, deep=False)#

Duplicate a model, optionally choose which fields to include, exclude and change.

Parameters:
  • include (Union[AbstractSetIntStr, MappingIntStrAny, None]) – fields to include in new model

  • exclude (Union[AbstractSetIntStr, MappingIntStrAny, None]) – fields to exclude from new model, as with values this takes precedence over include

  • update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep (bool) – set to True to make a deep copy of the model

Return type:

Model

Returns:

new model instance

dict(*, include=None, exclude=None, by_alias=False, skip_defaults=None, exclude_unset=False, exclude_defaults=False, exclude_none=False)#

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

Return type:

DictStrAny

classmethod from_orm(obj)#
Return type:

Model

json(*, include=None, exclude=None, by_alias=False, skip_defaults=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, encoder=None, models_as_dict=True, **dumps_kwargs)#

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

Return type:

unicode

classmethod parse_file(path, *, content_type=None, encoding='utf8', proto=None, allow_pickle=False)#
Return type:

Model

classmethod parse_obj(obj)#
Return type:

Model

classmethod parse_raw(b, *, content_type=None, encoding='utf8', proto=None, allow_pickle=False)#
Return type:

Model

classmethod schema(by_alias=True, ref_template='#/definitions/{model}')#
Return type:

DictStrAny

classmethod schema_json(*, by_alias=True, ref_template='#/definitions/{model}', **dumps_kwargs)#
Return type:

unicode

classmethod update_forward_refs(**localns)#

Try to update ForwardRefs on fields based on this Model, globalns and localns.

Return type:

None

classmethod validate(value)#
Return type:

Model

class jina.serve.runtimes.gateway.http.models.JinaResponseModel(**data)[source]#

Bases: BaseModel

Jina HTTP Response model. Only request_id and data are preserved.

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

header: HeaderProto#
parameters: Dict#
routes: List[RouteProto]#
data: Optional[List[PydanticDocument]]#
class Config[source]#

Bases: object

alias_generator()#
Return type:

str

allow_population_by_field_name = True#
classmethod construct(_fields_set=None, **values)#

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values

Return type:

Model

copy(*, include=None, exclude=None, update=None, deep=False)#

Duplicate a model, optionally choose which fields to include, exclude and change.

Parameters:
  • include (Union[AbstractSetIntStr, MappingIntStrAny, None]) – fields to include in new model

  • exclude (Union[AbstractSetIntStr, MappingIntStrAny, None]) – fields to exclude from new model, as with values this takes precedence over include

  • update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep (bool) – set to True to make a deep copy of the model

Return type:

Model

Returns:

new model instance

dict(*, include=None, exclude=None, by_alias=False, skip_defaults=None, exclude_unset=False, exclude_defaults=False, exclude_none=False)#

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

Return type:

DictStrAny

classmethod from_orm(obj)#
Return type:

Model

json(*, include=None, exclude=None, by_alias=False, skip_defaults=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, encoder=None, models_as_dict=True, **dumps_kwargs)#

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

Return type:

unicode

classmethod parse_file(path, *, content_type=None, encoding='utf8', proto=None, allow_pickle=False)#
Return type:

Model

classmethod parse_obj(obj)#
Return type:

Model

classmethod parse_raw(b, *, content_type=None, encoding='utf8', proto=None, allow_pickle=False)#
Return type:

Model

classmethod schema(by_alias=True, ref_template='#/definitions/{model}')#
Return type:

DictStrAny

classmethod schema_json(*, by_alias=True, ref_template='#/definitions/{model}', **dumps_kwargs)#
Return type:

unicode

classmethod update_forward_refs(**localns)#

Try to update ForwardRefs on fields based on this Model, globalns and localns.

Return type:

None

classmethod validate(value)#
Return type:

Model

class jina.serve.runtimes.gateway.http.models.JinaEndpointRequestModel(**data)[source]#

Bases: JinaRequestModel

Jina HTTP request model that allows customized endpoint.

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

exec_endpoint: str#
class Config#

Bases: object

alias_generator()#
Return type:

str

allow_population_by_field_name = True#
classmethod construct(_fields_set=None, **values)#

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values

Return type:

Model

copy(*, include=None, exclude=None, update=None, deep=False)#

Duplicate a model, optionally choose which fields to include, exclude and change.

Parameters:
  • include (Union[AbstractSetIntStr, MappingIntStrAny, None]) – fields to include in new model

  • exclude (Union[AbstractSetIntStr, MappingIntStrAny, None]) – fields to exclude from new model, as with values this takes precedence over include

  • update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep (bool) – set to True to make a deep copy of the model

Return type:

Model

Returns:

new model instance

dict(*, include=None, exclude=None, by_alias=False, skip_defaults=None, exclude_unset=False, exclude_defaults=False, exclude_none=False)#

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

Return type:

DictStrAny

classmethod from_orm(obj)#
Return type:

Model

json(*, include=None, exclude=None, by_alias=False, skip_defaults=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, encoder=None, models_as_dict=True, **dumps_kwargs)#

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

Return type:

unicode

classmethod parse_file(path, *, content_type=None, encoding='utf8', proto=None, allow_pickle=False)#
Return type:

Model

classmethod parse_obj(obj)#
Return type:

Model

classmethod parse_raw(b, *, content_type=None, encoding='utf8', proto=None, allow_pickle=False)#
Return type:

Model

classmethod schema(by_alias=True, ref_template='#/definitions/{model}')#
Return type:

DictStrAny

classmethod schema_json(*, by_alias=True, ref_template='#/definitions/{model}', **dumps_kwargs)#
Return type:

unicode

classmethod update_forward_refs(**localns)#

Try to update ForwardRefs on fields based on this Model, globalns and localns.

Return type:

None

classmethod validate(value)#
Return type:

Model

data: Optional[Union[List[PydanticDocument], Dict[str, List[PydanticDocument]]]]#
target_executor: Optional[str]#
parameters: Optional[Dict]#