python/ray/serve/deployment_state.py
def start(self, deployment_info: DeploymentInfo, version: DeploymentVersion):
        """
        Start a new actor for current DeploymentReplica instance.
        """
        self._max_concurrent_queries = (
            deployment_info.deployment_config.max_concurrent_queries
        )
        self._graceful_shutdown_timeout_s = (
            deployment_info.deployment_config.graceful_shutdown_timeout_s
        )
        self._health_check_period_s = (
            deployment_info.deployment_config.health_check_period_s
        )
        self._health_check_timeout_s = (
            deployment_info.deployment_config.health_check_timeout_s
        )

        self._actor_resources = deployment_info.replica_config.resource_dict
        # it is currently not possible to create a placement group
        # with no resources (https://github.com/ray-project/ray/issues/20401)
        has_resources_assigned = all(
            (r is not None and r > 0 for r in self._actor_resources.values())
        )
        if USE_PLACEMENT_GROUP and has_resources_assigned:
            self._placement_group = self.create_placement_group(
                self._placement_group_name, self._actor_resources
            )

        logger.debug(
            f"Starting replica {self.replica_tag} for deployment "
            f"{self.deployment_name}."
        )

        actor_def = deployment_info.actor_def
        init_args = (
            self.deployment_name,
            self.replica_tag,
            deployment_info.replica_config.init_args,
            deployment_info.replica_config.init_kwargs,
            deployment_info.deployment_config.to_proto_bytes(),
            version,
            self._controller_name,
            self._controller_namespace,
            self._detached,
        )
        # TODO(simon): unify the constructor arguments across language
        if (
            deployment_info.deployment_config.deployment_language
            == DeploymentLanguage.JAVA
        ):
            self._is_cross_language = True
            actor_def = ray.cross_language.java_actor_class(
                "io.ray.serve.RayServeWrappedReplica"
            )
            init_args = (
                # String deploymentName,
                self.deployment_name,
                # String replicaTag,
                self.replica_tag,
                # String deploymentDef
                deployment_info.replica_config.func_or_class_name,
                # byte[] initArgsbytes
                msgpack_serialize(deployment_info.replica_config.init_args),
                # byte[] deploymentConfigBytes,
                deployment_info.deployment_config.to_proto_bytes(),
                # byte[] deploymentVersionBytes,
                version.to_proto().SerializeToString(),
                # String controllerName
                self._controller_name,
            )

        self._actor_handle = actor_def.options(
            name=self._actor_name,
            namespace=self._controller_namespace,
            lifetime="detached" if self._detached else None,
            placement_group=self._placement_group,
            placement_group_capture_child_tasks=False,
            **deployment_info.replica_config.ray_actor_options,
        ).remote(*init_args)

        # Perform auto method name translation for java handles.
        # See https://github.com/ray-project/ray/issues/21474
        if self._is_cross_language:
            self._actor_handle = JavaActorHandleProxy(self._actor_handle)

        self._allocated_obj_ref = self._actor_handle.is_allocated.remote()
        self._ready_obj_ref = self._actor_handle.reconfigure.remote(
            deployment_info.deployment_config.user_config,
            # Ensure that `is_allocated` will execute before `reconfigure`,
            # because `reconfigure` runs user code that could block the replica
            # asyncio loop. If that happens before `is_allocated` is executed,
            # the `is_allocated` call won't be able to run.
            self._allocated_obj_ref,
        )

        Start a new actor for current DeploymentReplica instance.
        
Start a new actor for current DeploymentReplica instance.
Start a new actor for current DeploymentReplica instance .
def start(self, deployment_info: DeploymentInfo, version: DeploymentVersion):
        self._max_concurrent_queries = (
            deployment_info.deployment_config.max_concurrent_queries
        )
        self._graceful_shutdown_timeout_s = (
            deployment_info.deployment_config.graceful_shutdown_timeout_s
        )
        self._health_check_period_s = (
            deployment_info.deployment_config.health_check_period_s
        )
        self._health_check_timeout_s = (
            deployment_info.deployment_config.health_check_timeout_s
        )
        self._actor_resources = deployment_info.replica_config.resource_dict
        has_resources_assigned = all(
            (r is not None and r > 0 for r in self._actor_resources.values())
        )
        if USE_PLACEMENT_GROUP and has_resources_assigned:
            self._placement_group = self.create_placement_group(
                self._placement_group_name, self._actor_resources
            )
        logger.debug(
            f"Starting replica {self.replica_tag} for deployment "
            f"{self.deployment_name}."
        )
        actor_def = deployment_info.actor_def
        init_args = (
            self.deployment_name,
            self.replica_tag,
            deployment_info.replica_config.init_args,
            deployment_info.replica_config.init_kwargs,
            deployment_info.deployment_config.to_proto_bytes(),
            version,
            self._controller_name,
            self._controller_namespace,
            self._detached,
        )
        if (
            deployment_info.deployment_config.deployment_language
            == DeploymentLanguage.JAVA
        ):
            self._is_cross_language = True
            actor_def = ray.cross_language.java_actor_class(
                "io.ray.serve.RayServeWrappedReplica"
            )
            init_args = (
                self.deployment_name,
                self.replica_tag,
                deployment_info.replica_config.func_or_class_name,
                msgpack_serialize(deployment_info.replica_config.init_args),
                deployment_info.deployment_config.to_proto_bytes(),
                version.to_proto().SerializeToString(),
                self._controller_name,
            )
        self._actor_handle = actor_def.options(
            name=self._actor_name,
            namespace=self._controller_namespace,
            lifetime="detached" if self._detached else None,
            placement_group=self._placement_group,
            placement_group_capture_child_tasks=False,
            **deployment_info.replica_config.ray_actor_options,
        ).remote(*init_args)
        if self._is_cross_language:
            self._actor_handle = JavaActorHandleProxy(self._actor_handle)
        self._allocated_obj_ref = self._actor_handle.is_allocated.remote()
        self._ready_obj_ref = self._actor_handle.reconfigure.remote(
            deployment_info.deployment_config.user_config,
            self._allocated_obj_ref,
        )
def start ( self , deployment_info : DeploymentInfo , version : DeploymentVersion ) : self . _max_concurrent_queries = ( deployment_info . deployment_config . max_concurrent_queries ) self . _graceful_shutdown_timeout_s = ( deployment_info . deployment_config . graceful_shutdown_timeout_s ) self . _health_check_period_s = ( deployment_info . deployment_config . health_check_period_s ) self . _health_check_timeout_s = ( deployment_info . deployment_config . health_check_timeout_s ) self . _actor_resources = deployment_info . replica_config . resource_dict has_resources_assigned = all ( ( r is not None and r > 0 for r in self . _actor_resources . values ( ) ) ) if USE_PLACEMENT_GROUP and has_resources_assigned : self . _placement_group = self . create_placement_group ( self . _placement_group_name , self . _actor_resources ) logger . debug ( f"Starting replica {self.replica_tag} for deployment " f"{self.deployment_name}." ) actor_def = deployment_info . actor_def init_args = ( self . deployment_name , self . replica_tag , deployment_info . replica_config . init_args , deployment_info . replica_config . init_kwargs , deployment_info . deployment_config . to_proto_bytes ( ) , version , self . _controller_name , self . _controller_namespace , self . _detached , ) if ( deployment_info . deployment_config . deployment_language == DeploymentLanguage . JAVA ) : self . _is_cross_language = True actor_def = ray . cross_language . java_actor_class ( "io.ray.serve.RayServeWrappedReplica" ) init_args = ( self . deployment_name , self . replica_tag , deployment_info . replica_config . func_or_class_name , msgpack_serialize ( deployment_info . replica_config . init_args ) , deployment_info . deployment_config . to_proto_bytes ( ) , version . to_proto ( ) . SerializeToString ( ) , self . _controller_name , ) self . _actor_handle = actor_def . options ( name = self . _actor_name , namespace = self . _controller_namespace , lifetime = "detached" if self . _detached else None , placement_group = self . _placement_group , placement_group_capture_child_tasks = False , ** deployment_info . replica_config . ray_actor_options , ) . remote ( * init_args ) if self . _is_cross_language : self . _actor_handle = JavaActorHandleProxy ( self . _actor_handle ) self . _allocated_obj_ref = self . _actor_handle . is_allocated . remote ( ) self . _ready_obj_ref = self . _actor_handle . reconfigure . remote ( deployment_info . deployment_config . user_config , self . _allocated_obj_ref , )
Start a new actor for current DeploymentReplica instance.
Start a new actor for current DeploymentReplica instance .
"""
        Start a new actor for current DeploymentReplica instance.
        """ # it is currently not possible to create a placement group # with no resources (https://github.com/ray-project/ray/issues/20401) # TODO(simon): unify the constructor arguments across language # String deploymentName, # String replicaTag, # String deploymentDef # byte[] initArgsbytes # byte[] deploymentConfigBytes, # byte[] deploymentVersionBytes, # String controllerName # Perform auto method name translation for java handles. # See https://github.com/ray-project/ray/issues/21474 # Ensure that `is_allocated` will execute before `reconfigure`, # because `reconfigure` runs user code that could block the replica # asyncio loop. If that happens before `is_allocated` is executed, # the `is_allocated` call won't be able to run.
self
deployment_info
DeploymentInfo
version
DeploymentVersion