jina.peapods.pods package

Subpackages

Submodules

Module contents

class jina.peapods.pods.ExitFIFO[source]

Bases: contextlib.ExitStack

ExitFIFO changes the exiting order of exitStack to turn it into FIFO.

The __exit__ method is copied literally from ExitStack and changed the call: is_sync, cb = self._exit_callbacks.pop() to is_sync, cb = self._exit_callbacks.popleft()

class jina.peapods.pods.BasePod[source]

Bases: object

A BasePod is an immutable set of peas. They share the same input and output socket. Internally, the peas can run with the process/thread backend. They can be also run in their own containers on remote machines.

abstract start()[source]

Start to run all BasePea in this BasePod.

Note

If one of the BasePea fails to start, make sure that all of them are properly closed.

Return type

BasePod

abstract async rolling_update(*args, **kwargs)[source]

Roll update the Executors managed by the Pod

property role: jina.enums.PodRoleType

Return the role of this BasePod.

Return type

PodRoleType

property name: str

The name of this BasePod.

Return type

str

property connect_to_predecessor: str

True, if the Pod should open a connect socket in the HeadPea to the predecessor Pod. .. # noqa: DAR201

Return type

str

property head_host: str

Get the host of the HeadPea of this pod .. # noqa: DAR201

Return type

str

property head_port_in

Get the port_in of the HeadPea of this pod .. # noqa: DAR201

property tail_port_out

Get the port_out of the TailPea of this pod .. # noqa: DAR201

property head_zmq_identity

Get the zmq_identity of the HeadPea of this pod .. # noqa: DAR201

abstract property head_args: argparse.Namespace

Get the arguments for the head of this BasePod.

Return type

Namespace

abstract property tail_args: argparse.Namespace

Get the arguments for the tail of this BasePod.

Return type

Namespace

abstract join()[source]

Wait until all pods and peas exit.

property deployments: List[Dict]

Get deployments of the pod. The BasePod just gives one deployment.

Return type

List[Dict]

Returns

list of deployments

class jina.peapods.pods.Pod(args, needs=None)[source]

Bases: jina.peapods.pods.BasePod, jina.peapods.pods.ExitFIFO

A Pod is an immutable set of peas, which run in replicas. They share the same input and output socket. Internally, the peas can run with the process/thread backend. They can be also run in their own containers :type args: Union[Namespace, Dict] :param args: arguments parsed from the CLI :type needs: Optional[Set[str]] :param needs: pod names of preceding pods, the output of these pods are going into the input of this pod

needs

used in the jina.flow.Flow to build the graph

update_pea_args()[source]

Update args of all its peas based on Pod args. Including head/tail

update_worker_pea_args()[source]

Update args of all its worker peas based on Pod args. Does not touch head and tail

property first_pea_args: argparse.Namespace

Return the first non-head/tail pea’s args

Return type

Namespace

property host: str

Get the host name of this Pod

Return type

str

property head_args: argparse.Namespace

Get the arguments for the head of this Pod.

Return type

Namespace

property tail_args: argparse.Namespace

Get the arguments for the tail of this BasePod.

Return type

Namespace

property all_args: List[argparse.Namespace]

Get all arguments of all Peas in this BasePod.

Return type

List[Namespace]

property num_peas: int

Get the number of running BasePea

Return type

int

activate()[source]

Activate all peas in this pod

start()[source]

Start to run all BasePea in this BasePod.

Return type

Pod

Returns

started pod

Note

If one of the BasePea fails to start, make sure that all of them are properly closed.

wait_start_success()[source]

Block until all peas starts successfully.

If not successful, it will raise an error hoping the outer function to catch it

Return type

None

join()[source]

Wait until all peas exit

property is_ready: bool

Checks if Pod is ready

Note

A Pod is ready when all the Peas it contains are ready

Return type

bool

async rolling_update(dump_path=None, *, uses_with=None)[source]

Reload all Peas of this Pod.

Parameters
  • dump_path (Optional[str]) – the dump from which to read the data

  • uses_with (Optional[Dict]) – a Dictionary of arguments to restart the executor with