jina.serve.executors package
Submodules
Module contents
class jina.serve.executors.BaseExecutor(metas=None, requests=None, runtime_args=None, \*kwargs*)[source]
Bases: jina.jaml.JAMLCompatible
The base class of the executor, can be used to build encoder, indexer, etc.
Any executor inherited from BaseExecutor always has the meta defined in jina.executors.metas.defaults
.
All arguments in the __init__()
can be specified with a with
map in the YAML config. Example:
class MyAwesomeExecutor:
def __init__(awesomeness = 5):
pass
is equal to
jtype: MyAwesomeExecutor
with:
awesomeness: 5
metas and requests are always auto-filled with values from YAML config.
Parameters
metas (
Optional
[Dict
]) – a dict of metas fieldsrequests (
Optional
[Dict
]) – a dict of endpoint-function mappingruntime_args (
Optional
[Dict
]) – a dict of arguments injected fromRuntime
during runtimekwargs – additional extra keyword arguments to avoid failing when extra params ara passed that are not expected
close()[source]
Always invoked as executor is destroyed.
You can write destructor & saving logic here.
Return type
None
property workspace: Optional[str]
Get the workspace directory of the Executor.
Return type
Optional
[str
]Returns
returns the workspace of the current shard of this Executor.
classmethod from_hub(uri, context=None, uses_with=None, uses_metas=None, uses_requests=None, \*kwargs*)[source]
Construct an Executor from Hub.
Parameters
uri (
str
) – a hub Executor scheme starts with jinahub://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 fieldkwargs – other kwargs accepted by the CLI
jina hub pull
Return type
~T
Returns
the Hub Executor object.
class jina.serve.executors.ReducerExecutor(metas=None, requests=None, runtime_args=None, \*kwargs*)[source]
Bases: jina.serve.executors.BaseExecutor
ReducerExecutor is an Executor that performs a reduce operation on a matrix of DocumentArrays coming from shards. ReducerExecutor relies on DocumentArray.reduce_all to merge all DocumentArray into one DocumentArray which will be sent to the next deployment.
This Executor only adds a reduce endpoint to the BaseExecutor.
metas and requests are always auto-filled with values from YAML config.
Parameters
metas (
Optional
[Dict
]) – a dict of metas fieldsrequests (
Optional
[Dict
]) – a dict of endpoint-function mappingruntime_args (
Optional
[Dict
]) – a dict of arguments injected fromRuntime
during runtimekwargs – additional extra keyword arguments to avoid failing when extra params ara passed that are not expected
reduce(docs_matrix=[], \*kwargs*)[source]
Reduce docs_matrix into one DocumentArray using DocumentArray.reduce_all :type docs_matrix:
List
[ForwardRef
] :param docs_matrix: a List of DocumentArrays to be reduced :param kwargs: extra keyword arguments :return: the reduced DocumentArrayrequests = {‘/default’: <function ReducerExecutor.reduce>}