jina.serve.runtimes.gateway.http package#
Submodules#
- jina.serve.runtimes.gateway.http.app module
- jina.serve.runtimes.gateway.http.fastapi module
FastAPIBaseGateway
FastAPIBaseGateway.app
FastAPIBaseGateway.setup_server()
FastAPIBaseGateway.shutdown()
FastAPIBaseGateway.run_server()
FastAPIBaseGateway.host
FastAPIBaseGateway.is_valid_jaml()
FastAPIBaseGateway.load_config()
FastAPIBaseGateway.port
FastAPIBaseGateway.ports
FastAPIBaseGateway.protocols
FastAPIBaseGateway.save_config()
- jina.serve.runtimes.gateway.http.gateway module
- jina.serve.runtimes.gateway.http.models module
CustomConfig
CustomConfig.use_enum_values
CustomConfig.allow_population_by_field_name
CustomConfig.alias_generator
CustomConfig.allow_inf_nan
CustomConfig.allow_mutation
CustomConfig.anystr_lower
CustomConfig.anystr_strip_whitespace
CustomConfig.anystr_upper
CustomConfig.arbitrary_types_allowed
CustomConfig.copy_on_model_validation
CustomConfig.error_msg_templates
CustomConfig.extra
CustomConfig.fields
CustomConfig.frozen
CustomConfig.get_field_info()
CustomConfig.getter_dict
CustomConfig.json_dumps()
CustomConfig.json_encoders
CustomConfig.json_loads()
CustomConfig.keep_untouched
CustomConfig.max_anystr_length
CustomConfig.min_anystr_length
CustomConfig.orm_mode
CustomConfig.post_init_call
CustomConfig.prepare_field()
CustomConfig.schema_extra
CustomConfig.smart_union
CustomConfig.title
CustomConfig.underscore_attrs_are_private
CustomConfig.validate_all
CustomConfig.validate_assignment
protobuf_to_pydantic_model()
JinaHealthModel
JinaHealthModel.Config
JinaHealthModel.construct()
JinaHealthModel.copy()
JinaHealthModel.dict()
JinaHealthModel.from_orm()
JinaHealthModel.json()
JinaHealthModel.parse_file()
JinaHealthModel.parse_obj()
JinaHealthModel.parse_raw()
JinaHealthModel.schema()
JinaHealthModel.schema_json()
JinaHealthModel.update_forward_refs()
JinaHealthModel.validate()
JinaInfoModel
JinaInfoModel.jina
JinaInfoModel.envs
JinaInfoModel.Config
JinaInfoModel.construct()
JinaInfoModel.copy()
JinaInfoModel.dict()
JinaInfoModel.from_orm()
JinaInfoModel.json()
JinaInfoModel.parse_file()
JinaInfoModel.parse_obj()
JinaInfoModel.parse_raw()
JinaInfoModel.schema()
JinaInfoModel.schema_json()
JinaInfoModel.update_forward_refs()
JinaInfoModel.validate()
JinaRequestModel
JinaRequestModel.data
JinaRequestModel.target_executor
JinaRequestModel.parameters
JinaRequestModel.Config
JinaRequestModel.construct()
JinaRequestModel.copy()
JinaRequestModel.dict()
JinaRequestModel.from_orm()
JinaRequestModel.json()
JinaRequestModel.parse_file()
JinaRequestModel.parse_obj()
JinaRequestModel.parse_raw()
JinaRequestModel.schema()
JinaRequestModel.schema_json()
JinaRequestModel.update_forward_refs()
JinaRequestModel.validate()
JinaResponseModel
JinaResponseModel.header
JinaResponseModel.parameters
JinaResponseModel.routes
JinaResponseModel.data
JinaResponseModel.Config
JinaResponseModel.construct()
JinaResponseModel.copy()
JinaResponseModel.dict()
JinaResponseModel.from_orm()
JinaResponseModel.json()
JinaResponseModel.parse_file()
JinaResponseModel.parse_obj()
JinaResponseModel.parse_raw()
JinaResponseModel.schema()
JinaResponseModel.schema_json()
JinaResponseModel.update_forward_refs()
JinaResponseModel.validate()
JinaEndpointRequestModel
JinaEndpointRequestModel.exec_endpoint
JinaEndpointRequestModel.Config
JinaEndpointRequestModel.construct()
JinaEndpointRequestModel.copy()
JinaEndpointRequestModel.dict()
JinaEndpointRequestModel.from_orm()
JinaEndpointRequestModel.json()
JinaEndpointRequestModel.parse_file()
JinaEndpointRequestModel.parse_obj()
JinaEndpointRequestModel.parse_raw()
JinaEndpointRequestModel.schema()
JinaEndpointRequestModel.schema_json()
JinaEndpointRequestModel.update_forward_refs()
JinaEndpointRequestModel.validate()
JinaEndpointRequestModel.data
JinaEndpointRequestModel.target_executor
JinaEndpointRequestModel.parameters
Module contents#
- class jina.serve.runtimes.gateway.http.HTTPGateway(title=None, description=None, no_debug_endpoints=False, no_crud_endpoints=False, expose_endpoints=None, expose_graphql_endpoint=False, cors=False, **kwargs)[source]#
Bases:
FastAPIBaseGateway
HTTP Gateway implementation
- Initialize the gateway
Get the app from FastAPI as the REST interface.
- Parameters:
title (
Optional
[str
]) – The title of this HTTP server. It will be used in automatics docs such as Swagger UI.description (
Optional
[str
]) – The description of this HTTP server. It will be used in automatics docs such as Swagger UI.no_debug_endpoints (
Optional
[bool
]) – If set, /status /post endpoints are removed from HTTP interface.no_crud_endpoints (
Optional
[bool
]) –If set, /index, /search, /update, /delete endpoints are removed from HTTP interface.
Any executor that has @requests(on=…) bound with those values will receive data requests.
expose_endpoints (
Optional
[str
]) – A JSON string that represents a map from executor endpoints (@requests(on=…)) to HTTP endpoints.expose_graphql_endpoint (
Optional
[bool
]) – If set, /graphql endpoint is added to HTTP interface.cors (
Optional
[bool
]) – If set, a CORS middleware is added to FastAPI frontend to allow cross-origin access.kwargs – keyword args
- property app#
FastAPI app needed to define an HTTP Jina Gateway
- Returns:
FastAPI app
- property host#
Gets the host from the runtime_args :return: The host where to bind the gateway
- static is_valid_jaml(obj)#
Verifies the yaml syntax of a given object by first serializing it and attempting to deserialize and catch parser errors :type obj:
Dict
:param obj: yaml object :rtype:bool
:return: whether the syntax is valid or not
- classmethod load_config(source, *, allow_py_modules=True, substitute=True, context=None, uses_with=None, uses_metas=None, uses_requests=None, extra_search_paths=None, py_modules=None, runtime_args=None, uses_dynamic_batching=None, **kwargs)#
A high-level interface for loading configuration with features of loading extra py_modules, substitute env & context variables. Any class that implements
JAMLCompatible
mixin can enjoy this feature, e.g.BaseFlow
,BaseExecutor
,BaseGateway
and all their subclasses.- Support substitutions in YAML:
Environment variables:
${{ ENV.VAR }}
(recommended),$VAR
(deprecated).Context dict (
context
):${{ CONTEXT.VAR }}``(recommended), ``${{ VAR }}
.Internal reference via
this
androot
:${{this.same_level_key}}
,${{root.root_level_key}}
Substitutions are carried in the order and multiple passes to resolve variables with best effort.
!BaseEncoder metas: name: ${{VAR_A}} # env or context variables workspace: my-${{this.name}} # internal reference
# load Executor from yaml file BaseExecutor.load_config('a.yml') # load Executor from yaml file and substitute environment variables os.environ['VAR_A'] = 'hello-world' b = BaseExecutor.load_config('a.yml') assert b.name == 'hello-world' # load Executor from yaml file and substitute variables from a dict b = BaseExecutor.load_config('a.yml', context={'VAR_A': 'hello-world'}) assert b.name == 'hello-world' # disable substitute b = BaseExecutor.load_config('a.yml', substitute=False)
- Parameters:
source (
Union
[str
,TextIO
,Dict
]) – the multi-kind source of the configs.allow_py_modules (
bool
) – allow importing plugins specified bypy_modules
in YAML at any levelssubstitute (
bool
) – substitute environment, internal reference and context variables.context (
Optional
[Dict
[str
,Any
]]) – context replacement variables in a dict, the value of the dict is the replacement.uses_with (
Optional
[Dict
]) – dictionary of parameters to overwrite from the default config’s with fielduses_metas (
Optional
[Dict
]) – dictionary of parameters to overwrite from the default config’s metas fielduses_requests (
Optional
[Dict
]) – dictionary of parameters to overwrite from the default config’s requests fieldextra_search_paths (
Optional
[List
[str
]]) – extra paths used when looking for executor yaml filespy_modules (
Optional
[str
]) – Optional py_module from which the object need to be loadedruntime_args (
Optional
[Dict
[str
,Any
]]) – Optional dictionary of parameters runtime_args to be directly passed without being parsed into a yaml configuses_dynamic_batching (
Optional
[Dict
]) – dictionary of parameters to overwrite from the default config’s dynamic_batching fieldkwargs – kwargs for parse_config_source
- Return type:
- Returns:
JAMLCompatible
object
- property port#
Gets the first port of the port list argument. To be used in the regular case where a Gateway exposes a single port :return: The first port to be exposed
- property ports#
Gets all the list of ports from the runtime_args as a list. :return: The lists of ports to be exposed
- property protocols#
Gets all the list of protocols from the runtime_args as a list. :return: The lists of protocols to be exposed
- async run_server()#
Run HTTP server forever
- save_config(filename=None)#
Save the object’s config into a YAML file.
- Parameters:
filename (
Optional
[str
]) – file path of the yaml file, if not given thenconfig_abspath
is used
- async setup_server()#
Initialize and return GRPC server
- async shutdown()#
Free resources allocated when setting up HTTP server