jina.peapods.pods

class jina.peapods.pods.BasePod(args, needs=None)[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 :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 role

Return the role of this BasePod.

Return type

PodRoleType

Returns

role type

property is_singleton

Return if the Pod contains only a single Pea.

Return type

bool

Returns

true if there is only one pea, else false

property name

The name of this BasePod.

Return type

str

Returns

name of the pod

property port_expose

Get the grpc port number.

Return type

int

Returns

exposed port

property host

Get the host name of this Pod.

Return type

str

Returns

host name

property host_in

Get the host_in of this pod.

Return type

str

Returns

host name of incoming requests

property host_out

Get the host_out of this pod.

Return type

str

Returns

host name of outgoing requests

property address_in

Get the full incoming address of this pod.

Return type

str

Returns

address for incoming requests

property address_out

Get the full outgoing address of this pod.

Return type

str

Returns

address for outgoing requests.

property first_pea_args

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

Return type

Namespace

Returns

arguments of the first pea which is not a head pea or tail pea

property head_args

Get the arguments for the head of this BasePod.

Returns

arguments of the head pea

property tail_args

Get the arguments for the tail of this BasePod.

Returns

arguments of the tail pea

property all_args

Get all arguments of all Peas in this BasePod.

Return type

List[Namespace]

Returns

arguments for all peas

property num_peas

Get the number of running BasePea.

Return type

int

Returns

total number of peas including head and tail

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 read.

Return type

bool

Returns

true if the pea is ready to serve requests

Note

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