jina.drivers

jina.drivers.store_init_kwargs(func)[source]

Mark the args and kwargs of __init__() later to be stored via save_config() in YAML

class jina.drivers.DriverType[source]

Bases: type

static register_class(cls)[source]
class jina.drivers.BaseDriver(*args, **kwargs)[source]

Bases: object

A BaseDriver is a logic unit above the jina.peapods.pea.BasePea. It reads the protobuf message, extracts/modifies the required information and then return the message back to jina.peapods.pea.BasePea.

A BaseDriver needs to be attached to a jina.peapods.pea.BasePea before using. This is done by attach(). Note that a deserialized BaseDriver from file is always unattached.

store_args_kwargs = False

set this to True to save args (in a list) and kwargs (in a map) in YAML config

attached = None

represent if this driver is attached to a jina.peapods.pea.BasePea (& jina.executors.BaseExecutor)

attach(pea, *args, **kwargs)[source]

Attach this driver to a jina.peapods.pea.BasePea

Parameters

pea (BasePea) – the pea to be attached.

property req

Get the current request, shortcut to self.pea.request

Return type

Request

property msg

Get the current request, shortcut to self.pea.message

Return type

Message

property envelope

Get the current request, shortcut to self.pea.message

Return type

Envelope

property logger

Shortcut to self.pea.logger

Return type

logging.Logger

classmethod to_yaml(representer, data)[source]

Required by ruamel.yaml.constructor

classmethod from_yaml(constructor, node)[source]

Required by ruamel.yaml.constructor

class jina.drivers.BaseExecutableDriver(executor=None, method=None, *args, **kwargs)[source]

Bases: jina.drivers.BaseDriver

A BaseExecutableDriver is an intermediate logic unit between the jina.peapods.pea.BasePea and jina.executors.BaseExecutor It reads the protobuf message, extracts/modifies the required information and then sends to the jina.executors.BaseExecutor, finally it returns the message back to jina.peapods.pea.BasePea.

A BaseExecutableDriver needs to be attached to a jina.peapods.pea.BasePea and jina.executors.BaseExecutor before using. This is done by attach(). Note that a deserialized BaseDriver from file is always unattached.

Initialize a BaseExecutableDriver

Parameters
  • executor (Optional[str]) – the name of the sub-executor, only necessary when jina.executors.compound.CompoundExecutor is used

  • method (Optional[str]) – the function name of the executor that the driver feeds to

property exec

the executor that attached

Return type

AnyExecutor

property exec_fn

the function of jina.executors.BaseExecutor() to call

Return type

Callable

attach(executor, *args, **kwargs)[source]

Attach the driver to a jina.executors.BaseExecutor