jina.orchestrate.deployments package

Subpackages

Module contents

class jina.orchestrate.deployments.BaseDeployment[source]

Bases: contextlib.ExitStack

A BaseDeployment is an immutable set of pods. Internally, the pods 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 Pod in this BaseDeployment.

    Note

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

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

    Roll update the Executors managed by the Deployment

  • abstract async scale(\args, **kwargs*)[source]

    Scale the amount of replicas of a given Executor.

  • property role: jina.enums.DeploymentRoleType

    Return the role of this BaseDeployment.

  • property name: str

    The name of this BaseDeployment.

    • Return type

      str

  • property head_host: str

    Get the host of the HeadPod of this deployment .. # noqa: DAR201

    • Return type

      str

  • property head_port_in

    Get the port_in of the HeadPod of this deployment .. # noqa: DAR201

  • abstract property head_args: argparse.Namespace

    Get the arguments for the head of this BaseDeployment.

    • Return type

      Namespace

  • abstract join()[source]

    Wait until all deployment and pods exit.

  • property deployments: List[Dict]

    Get deployments of the deployment. The BaseDeployment just gives one deployment.

    • Return type

      List[Dict]

      Returns

      list of deployments

class jina.orchestrate.deployments.Deployment(args, needs=None)[source]

Bases: jina.orchestrate.deployments.BaseDeployment

A Deployment is an immutable set of pods, which run in replicas. They share the same input and output socket. Internally, the pods 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: deployments names of preceding deployments, the output of these deployments are going into the input of this deployment

  • needs

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

  • update_pod_args()[source]

    Update args of all its pods based on Deployment args. Including head/tail

  • update_worker_pod_args()[source]

    Update args of all its worker pods based on Deployment args. Does not touch head and tail

  • property is_sandbox: bool

    Check if this deployment is a sandbox.

    • Return type

      bool

      Returns

      True if this deployment is provided as a sandbox, False otherwise

  • property external: bool

    Check if this deployment is external.

    • Return type

      bool

      Returns

      True if this deployment is provided as an external deployment, False otherwise

  • property protocol

    • Returns

      the protocol of this deployment, https or http

  • property first_pod_args: argparse.Namespace

    Return the first worker pod’s args

    • Return type

      Namespace

  • property host: str

    Get the host name of this deployment

    • Return type

      str

  • property head_args: argparse.Namespace

    Get the arguments for the head of this Deployment.

    • Return type

      Namespace

  • property uses_before_args: argparse.Namespace

    Get the arguments for the uses_before of this Deployment.

    • Return type

      Namespace

  • property uses_after_args: argparse.Namespace

    Get the arguments for the uses_after of this Deployment.

    • Return type

      Namespace

  • property all_args: List[argparse.Namespace]

    Get all arguments of all Pods in this BaseDeployment.

    • Return type

      List[Namespace]

  • property num_pods: int

    Get the number of running Pod

    • Return type

      int

  • activate()[source]

    Activate all worker pods in this deployment by registering them with the head

  • static get_worker_host(pod_args, pod, head_pod)[source]

    Check if the current pod and head are both containerized on the same host If so __docker_host__ needs to be advertised as the worker’s address to the head

    • Parameters

      • pod_args – arguments of the worker pod

      • pod – the worker pod

      • head_pod – head pod communicating with the worker pod

      Returns

      host to use in activate messages

  • start()[source]

    Start to run all Pod in this BaseDeployment.

    • Return type

      Deployment

      Returns

      started deployment

    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 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 pods exit

  • property is_ready: bool

    Checks if Deployment is ready

    Note

    A Deployment is ready when all the Pods it contains are ready

    • Return type

      bool

  • async rolling_update(uses_with=None)[source]

    Reload all Pods of this Deployment.

    • Parameters

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

  • async scale(replicas)[source]

    Scale the amount of replicas of a given Executor.

    • Parameters

      replicas (int) – The number of replicas to scale to