def actor_def(self): # Delayed import as replica depends on this file. from ray.serve.replica import create_replica_wrapper if self._cached_actor_def is None: assert self.actor_name is not None assert ( self.replica_config.import_path is not None or self.serialized_deployment_def is not None ) if self.replica_config.import_path is not None: self._cached_actor_def = ray.remote( create_replica_wrapper( self.actor_name, import_path=self.replica_config.import_path, ) ) else: self._cached_actor_def = ray.remote( create_replica_wrapper( self.actor_name, serialized_deployment_def=self.serialized_deployment_def, ) ) return self._cached_actor_def
def deploy(self, name: str, deployment_config_proto_bytes: bytes, replica_config: ReplicaConfig, version: Optional[str], prev_version: Optional[str], route_prefix: Optional[str], deployer_job_id: "Optional[ray._raylet.JobID]" = None ) -> Tuple[Optional[GoalId], bool]: if route_prefix is not None: assert route_prefix.startswith("/") deployment_config = DeploymentConfig.from_proto_bytes( deployment_config_proto_bytes) if prev_version is not None: existing_deployment_info = ( self.deployment_state_manager.get_deployment(name)) if (existing_deployment_info is None or not existing_deployment_info.version): raise ValueError( f"prev_version '{prev_version}' is specified but " "there is no existing deployment.") if existing_deployment_info.version != prev_version: raise ValueError( f"prev_version '{prev_version}' " "does not match with the existing " f"version '{existing_deployment_info.version}'.") autoscaling_config = deployment_config.autoscaling_config if autoscaling_config is not None: # TODO: is this the desired behaviour? Should this be a setting? deployment_config.num_replicas = autoscaling_config.min_replicas autoscaling_policy = BasicAutoscalingPolicy(autoscaling_config) else: autoscaling_policy = None deployment_info = DeploymentInfo( actor_def=ray.remote( create_replica_wrapper( name, replica_config.serialized_deployment_def)), version=version, deployment_config=deployment_config, replica_config=replica_config, deployer_job_id=deployer_job_id, start_time_ms=int(time.time() * 1000), autoscaling_policy=autoscaling_policy) # TODO(architkulkarni): When a deployment is redeployed, even if # the only change was num_replicas, the start_time_ms is refreshed. # Is this the desired behaviour? goal_id, updating = self.deployment_state_manager.deploy( name, deployment_info) endpoint_info = EndpointInfo(route=route_prefix) self.endpoint_state.update_endpoint(name, endpoint_info) return goal_id, updating
def actor_def(self): # Delayed import as replica depends on this file. from ray.serve.replica import create_replica_wrapper if self._cached_actor_def is None: assert self.actor_name is not None assert self.serialized_deployment_def is not None self._cached_actor_def = ray.remote( create_replica_wrapper(self.actor_name, self.serialized_deployment_def)) return self._cached_actor_def
def actor_def(self): # Delayed import as replica depends on this file. from ray.serve.replica import create_replica_wrapper if self._cached_actor_def is None: assert self.actor_name is not None self._cached_actor_def = ray.remote( **REPLICA_DEFAULT_ACTOR_OPTIONS)(create_replica_wrapper( self.actor_name)) return self._cached_actor_def
def deploy( self, name: str, backend_config_proto_bytes: bytes, replica_config: ReplicaConfig, version: Optional[str], prev_version: Optional[str], route_prefix: Optional[str], deployer_job_id: "Optional[ray._raylet.JobID]" = None ) -> Tuple[Optional[GoalId], bool]: if route_prefix is not None: assert route_prefix.startswith("/") backend_config = BackendConfig.from_proto_bytes( backend_config_proto_bytes) if prev_version is not None: existing_backend_info = self.backend_state_manager.get_backend( name) if (existing_backend_info is None or not existing_backend_info.version): raise ValueError( f"prev_version '{prev_version}' is specified but " "there is no existing deployment.") if existing_backend_info.version != prev_version: raise ValueError(f"prev_version '{prev_version}' " "does not match with the existing " f"version '{existing_backend_info.version}'.") backend_info = BackendInfo(actor_def=ray.remote( create_replica_wrapper(name, replica_config.serialized_backend_def)), version=version, backend_config=backend_config, replica_config=replica_config, deployer_job_id=deployer_job_id, start_time_ms=int(time.time() * 1000)) # TODO(architkulkarni): When a deployment is redeployed, even if # the only change was num_replicas, the start_time_ms is refreshed. # This is probably not the desired behavior for an autoscaling # deployment, which redeploys very often to change num_replicas. goal_id, updating = self.backend_state_manager.deploy_backend( name, backend_info) endpoint_info = EndpointInfo(route=route_prefix) self.endpoint_state.update_endpoint(name, endpoint_info) return goal_id, updating