jina.peapods.pods.compound module

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

Bases: jina.peapods.pods.BasePod, contextlib.ExitStack

A CompoundPod is a immutable set of pods, which run in parallel. A CompoundPod is an abstraction using a composable pattern to abstract the usage of parallel Pods that act as shards.

CompoundPod will make sure to add a HeadPea and a TailPea to serve as routing/merging pattern for the different Pod shards

Parameters
  • args (Union[Namespace, Dict]) – pod arguments parsed from the CLI. These arguments will be used for each of the shards

  • needs (Optional[Set[str]]) – 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

head_args = None
tail_args = None
assign_shards()[source]

Assign shards to the CompoundPod

property port_jinad: int

Get the JinaD remote port

Return type

int

property host: str

Get the host name of this Pod

Return type

str

property num_peas: int

Get the number of running Pod

Return type

int

Returns

total number of peas including head and tail

start()[source]

Start to run all Pod and Pea in this CompoundPod.

Return type

CompoundPod

Returns

started CompoundPod

Note

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

wait_start_success()[source]

Block until all pods and peas start successfully. If not successful, it will raise an error hoping the outer function to catch it

Return type

None

join()[source]

Wait until all pods and peas exit.

property is_ready: bool

Checks if Pod is read. :rtype: bool :return: true if the peas and pods are ready to serve requests

Note

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

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

Reload all Pods of this Compound Pod. :type dump_path: Optional[str] :param dump_path: backwards compatibility This function was only accepting dump_path as the only potential arg to override :type uses_with: Optional[Dict] :param uses_with: a Dictionary of arguments to restart the executor with