jina.peapods.pod

class jina.peapods.pod.BasePod(args)[source]

Bases: contextlib.ExitStack

A BasePod is a 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

Parameters

args (Union[Namespace, Dict]) – arguments parsed from the CLI

property is_singleton

Return if the Pod contains only a single Pea

Return type

bool

property is_idle

A Pod is idle when all its peas are idle, see also jina.peapods.pea.Pea.is_idle.

Return type

bool

close_if_idle()[source]

Check every second if the pod is in idle, if yes, then close the pod

property name

The name of this BasePod.

Return type

str

property port_expose

Get the grpc port number

Return type

int

property host

Get the grpc host name

Return type

str

property head_args

Get the arguments for the head of this BasePod.

property tail_args

Get the arguments for the tail of this BasePod.

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

set_runtime(runtime)[source]

Set the parallel runtime of this BasePod.

Parameters

runtime (str) – possible values: process, thread

start_sentinels()[source]
Return type

None

start()[source]

Start to run all Peas in this BasePod.

Remember to close the BasePod with close().

Note that this method has a timeout of timeout_ready set in CLI, which is inherited from jina.peapods.peas.BasePea

Return type

FlowPod

property log_iterator

Get the last log using iterator

The BasePod log iterator goes through all peas log_iterator and poll them sequentially. If non all them is active anymore, aka is_event_loop is False, then the iterator ends.

Warning

The log may not strictly follow the time order given that we are polling the log from all peas in the sequential manner.

property is_shutdown
Return type

bool

property status

The status of a BasePod is the list of status of all its Peas

Return type

List

is_ready()[source]

Wait till the ready signal of this BasePod.

The pod is ready only when all the contained Peas returns is_ready

Return type

bool

join()[source]

Wait until all peas exit

class jina.peapods.pod.MutablePod(args)[source]

Bases: jina.peapods.pod.BasePod

A MutablePod is a pod where all peas and their connections are given

Parameters

args (Union[Namespace, Dict]) – arguments parsed from the CLI

class jina.peapods.pod.FlowPod(kwargs, needs=None, parser=<function set_pod_parser>, pod_role=<PodRoleType.POD: 0>)[source]

Bases: jina.peapods.pod.BasePod

A FlowPod is like a BasePod, but it exposes more interfaces for tweaking its connections with other Pods, which comes in handy when used in the Flow API.

Note

Unlike BasePod, this class takes a dict as the first argument.

Parameters
  • kwargs (Dict) – unparsed argument in dict, if given the

  • needs (Optional[Set[str]]) – a list of names this BasePod needs to receive message from

needs = None

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

to_cli_command()[source]
static connect(first, second, first_socket_type)[source]

Connect two Pods

Parameters
  • first (BasePod) – the first BasePod

  • second (BasePod) – the second BasePod

  • first_socket_type (SocketType) – socket type of the first BasePod, availables are PUSH_BIND, PUSH_CONNECT, PUB_BIND

Return type

None

connect_to_tail_of(pod)[source]

Eliminate the head node by connecting prev_args node directly to peas

connect_to_head_of(pod)[source]

Eliminate the tail node by connecting next_args node directly to peas

start()[source]

Start to run all Peas in this BasePod.

Remember to close the BasePod with close().

Note that this method has a timeout of timeout_ready set in CLI, which is inherited from jina.peapods.peas.BasePea

Return type

FlowPod

class jina.peapods.pod.GatewayPod(args)[source]

Bases: jina.peapods.pod.BasePod

A BasePod that holds a Gateway

Parameters

args (Union[Namespace, Dict]) – arguments parsed from the CLI

start()[source]

Start to run all Peas in this BasePod.

Remember to close the BasePod with close().

Note that this method has a timeout of timeout_ready set in CLI, which is inherited from jina.peapods.peas.BasePea

Return type

GatewayPod

class jina.peapods.pod.GatewayFlowPod(kwargs=None, needs=None)[source]

Bases: jina.peapods.pod.GatewayPod, jina.peapods.pod.FlowPod

A FlowPod that holds a Gateway

Parameters

args – arguments parsed from the CLI