jina.peapods.pods package

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.

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

property role

Return the role of this BasePod.

Return type

PodRoleType

property name

The name of this BasePod.

Return type

str

property head_host

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

Get the arguments for the head of this BasePod.

Return type

Namespace

abstract property tail_args

Get the arguments for the tail of this BasePod.

Return type

Namespace

abstract join()[source]

Wait until all pods and peas exit.

abstract is_singleton()[source]

Return if the Pod contains only a single Pea

Return type

bool

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

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

A BasePod is an immutable set of peas, which run in parallel. 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

property is_singleton

Return if the Pod contains only a single Pea

Return type

bool

property first_pea_args

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

Return type

Namespace

property port_expose

Get the grpc port number

Return type

int

property host

Get the host name of this Pod

Return type

str

property head_args

Get the arguments for the head of this Pod.

Return type

Namespace

property tail_args

Get the arguments for the tail of this BasePod.

Return type

Namespace

property all_args

Get all arguments of all Peas in this BasePod.

Return type

List[Namespace]

property num_peas

Get the number of running BasePea

Return type

int

start()[source]

Start to run all BasePea in this BasePod.

Return type

BasePod

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

Checks if Pod is ready

Note

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

Return type

bool