Start the current DeploymentReplica instance. The replica will be in the STARTING and PENDING_ALLOCATION states until the deployment scheduler schedules the underlying actor. Args: deployment_info: Configuration info for the deployment. assign_rank_c
(
self,
deployment_info: DeploymentInfo,
assign_rank_callback: Callable[[ReplicaID], ReplicaRank],
gang_placement_group: Optional[PlacementGroup] = None,
gang_pg_index: Optional[int] = None,
gang_context: Optional[GangContext] = None,
)
| 1011 | return self._last_health_check_failed |
| 1012 | |
| 1013 | def start( |
| 1014 | self, |
| 1015 | deployment_info: DeploymentInfo, |
| 1016 | assign_rank_callback: Callable[[ReplicaID], ReplicaRank], |
| 1017 | gang_placement_group: Optional[PlacementGroup] = None, |
| 1018 | gang_pg_index: Optional[int] = None, |
| 1019 | gang_context: Optional[GangContext] = None, |
| 1020 | ) -> ReplicaSchedulingRequest: |
| 1021 | """Start the current DeploymentReplica instance. |
| 1022 | |
| 1023 | The replica will be in the STARTING and PENDING_ALLOCATION states |
| 1024 | until the deployment scheduler schedules the underlying actor. |
| 1025 | |
| 1026 | Args: |
| 1027 | deployment_info: Configuration info for the deployment. |
| 1028 | assign_rank_callback: Callback to assign rank to the replica. |
| 1029 | gang_placement_group: Pre-created gang PG to schedule this replica on. |
| 1030 | gang_pg_index: Bundle index within the gang PG for this replica. |
| 1031 | gang_context: Gang context for this replica. |
| 1032 | |
| 1033 | Returns: |
| 1034 | ReplicaSchedulingRequest: The scheduling request for the replica. |
| 1035 | """ |
| 1036 | self._assign_rank_callback = assign_rank_callback |
| 1037 | self._actor_resources = deployment_info.replica_config.resource_dict |
| 1038 | self._ingress = deployment_info.ingress |
| 1039 | self._gang_placement_group = gang_placement_group |
| 1040 | self._gang_pg_index = gang_pg_index |
| 1041 | self._gang_context = gang_context |
| 1042 | # it is currently not possible to create a placement group |
| 1043 | # with no resources (https://github.com/ray-project/ray/issues/20401) |
| 1044 | self._deployment_is_cross_language = ( |
| 1045 | deployment_info.deployment_config.is_cross_language |
| 1046 | ) |
| 1047 | |
| 1048 | logger.info( |
| 1049 | f"Starting {self.replica_id}.", |
| 1050 | extra={"log_to_stderr": False}, |
| 1051 | ) |
| 1052 | |
| 1053 | actor_def = deployment_info.actor_def |
| 1054 | if ( |
| 1055 | deployment_info.deployment_config.deployment_language |
| 1056 | == DeploymentLanguage.PYTHON |
| 1057 | ): |
| 1058 | if deployment_info.replica_config.serialized_init_args is None: |
| 1059 | serialized_init_args = cloudpickle.dumps(()) |
| 1060 | else: |
| 1061 | serialized_init_args = ( |
| 1062 | cloudpickle.dumps( |
| 1063 | msgpack_deserialize( |
| 1064 | deployment_info.replica_config.serialized_init_args |
| 1065 | ) |
| 1066 | ) |
| 1067 | if self._deployment_is_cross_language |
| 1068 | else deployment_info.replica_config.serialized_init_args |
| 1069 | ) |
| 1070 | init_args = ( |