jina.executors package

Submodules

Module contents

class jina.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 fields

  • requests (Optional[Dict]) – a dict of endpoint-function mapping

  • runtime_args (Optional[Dict]) – a dict of arguments injected from Runtime during runtime

  • kwargs – 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: str

Get the path of the current shard.

Return type

str

Returns

returns the workspace of the shard of this Executor.

class jina.executors.ExecutorType(*args, **kwargs)[source]

Bases: jina.jaml.JAMLCompatibleType, type

The class of Executor type, which is the metaclass of BaseExecutor.

# noqa: DAR101 # noqa: DAR102

Returns

Executor class

static register_class(cls)[source]

Register a class and wrap update, train, aggregate functions.

Parameters

cls – The class.

Returns

The class, after being registered.