# jina.executors.metas¶

The default meta config that all executors follow, they can be overrided by the YAML config

Warning

When you define your own Executor class, make sure your attributes/methods name do not conflict with the name listed below.

Note

Essentially, the meta config can be set in two places: as part of the YAML file, or as the class attribute via __init__() or in class definition. When multiple meta specification exists, the overwrite priority is:

metas defined in YAML > metas defined as class attribute > metas default values listed below

Any executor inherited from BaseExecutor always has the following meta fields:

is_trained

indicates if the executor is trained or not, if not then methods decorated by @required_train() can not be executed.

Type

bool

Default

False

is_updated

indicates if the executor is updated or changed since last save, if not then save() will do nothing. A forced save is possible to use touch() before save()

Type

bool

Default

False

batch_size

the size of each batch, methods decorated by @batching() will respect this. useful when incoming data is too large to fit into (GPU) memory.

Type

int

Default

None

workspace

the working directory, for persisting the artifacts of the executor. An artifact is a file or collection of files used during a workflow run.

Type

str

Default

environment variable JINA_EXECUTOR_WORKDIR, if not set then using current working dir, aka cwd.

name

the name of the executor.

Type

str

Default

class name plus a random string

on_gpu

if the executor is set to run on GPU.

Type

bool

Default

False

py_modules

the external python module paths. it is useful when you want to load external python modules using BaseExecutor.load_config() from a YAML file. If a relative path is given then the root path is set to the path of the current YAML file.

Type

str/List[str]

Default

None

replica_id

the integer index used for distinguish each replica of this executor, useful in replica_workspace

Type

int

Default

'{root.metas.replica_id}'

separated_workspace

whether to isolate the data of the parallel of this executor. If True, then each replica works in its own workspace specified in replica_workspace

Type

bool

Default

'{root.metas.separated_workspace}'

replica_workspace

the workspace of each replica, useful when separated_workspace is set to True. All data and IO operations related to this replica will be conducted under this workspace. It is often set as the sub-directory of workspace.

Type

str

Default

'{root.metas.workspace}/{root.metas.name}-{root.metas.replica_id}'

Warning

name and workspace must be set if you want to serialize/deserialize this executor.

Note

separated_workspace, replica_workspace and replica_id is set in a way that when the executor A is used as a component of a jina.executors.compound.CompoundExecutor B, then A’s setting will be overrided by B’s counterpart.

These meta fields can be accessed via self.is_trained or loaded from a YAML config via load_config():

!MyAwesomeExecutor
with:
...
metas:
name: my_transformer  # a customized name
is_trained: true  # indicate the model has been trained
workspace: ./  # path for serialize/deserialize

jina.executors.metas.get_default_metas()[source]

Get a copy of default meta variables

Return type

Dict

jina.executors.metas.fill_metas_with_defaults(d)[source]

Fill the incomplete metas field with complete default values

Parameters

d (Dict) – the loaded YAML map

Return type

Dict