async def create_backend(self, backend_tag, backend_config, func_or_class, actor_init_args): backend_config_dict = dict(backend_config) backend_worker = create_backend_worker(func_or_class) assert backend_tag not in self.get_all_backends(), \ "Cannot create backend '{}' because a backend" \ "with that name already exists.".format(backend_tag) # Save creator which starts replicas. self.backend_table.register_backend(backend_tag, backend_worker) # Save information about configurations needed to start the replicas. self.backend_table.register_info(backend_tag, backend_config_dict) # Save the initial arguments needed by replicas. self.backend_table.save_init_args(backend_tag, actor_init_args) # Set the backend config inside the router # (particularly for max-batch-size). [router] = self.get_router() await router.set_backend_config.remote(backend_tag, backend_config_dict) await self.scale_replicas(backend_tag, backend_config_dict["num_replicas"])
async def create_backend(self, backend_tag, backend_config, replica_config): """Register a new backend under the specified tag.""" async with self.write_lock: backend_worker = create_backend_worker( replica_config.func_or_class) # Save creator that starts replicas, the arguments to be passed in, # and the configuration for the backends. self.backends[backend_tag] = BackendInfo(backend_worker, backend_config, replica_config) self._scale_replicas(backend_tag, backend_config.num_replicas) # NOTE(edoakes): we must write a checkpoint before starting new # or pushing the updated config to avoid inconsistent state if we # crash while making the change. self._checkpoint() await self._start_pending_replicas() # Set the backend config inside the router # (particularly for max-batch-size). await self.router.set_backend_config.remote( backend_tag, backend_config) await self.broadcast_backend_config(backend_tag)
async def create_backend(self, backend_tag: BackendTag, backend_config: BackendConfig, replica_config: ReplicaConfig) -> None: """Register a new backend under the specified tag.""" async with self.write_lock: # Ensures this method is idempotent. backend_info = self.configuration_store.get_backend(backend_tag) if backend_info is not None: if (backend_info.backend_config == backend_config and backend_info.replica_config == replica_config): return backend_worker = create_backend_worker( replica_config.func_or_class) # Save creator that starts replicas, the arguments to be passed in, # and the configuration for the backends. self.configuration_store.add_backend( backend_tag, BackendInfo( worker_class=backend_worker, backend_config=backend_config, replica_config=replica_config)) metadata = backend_config.internal_metadata if metadata.autoscaling_config is not None: self.autoscaling_policies[ backend_tag] = BasicAutoscalingPolicy( backend_tag, metadata.autoscaling_config) try: self.actor_reconciler._scale_replicas( self.configuration_store.backends, backend_tag, backend_config.num_replicas) except RayServeException as e: del self.configuration_store.backends[backend_tag] raise e # NOTE(edoakes): we must write a checkpoint before starting new # or pushing the updated config to avoid inconsistent state if we # crash while making the change. self._checkpoint() await self.actor_reconciler._start_pending_replicas( self.configuration_store) # Set the backend config inside the router # (particularly for max-batch-size). await asyncio.gather(*[ router.set_backend_config.remote(backend_tag, backend_config) for router in self.actor_reconciler.router_handles() ]) await self.broadcast_backend_config(backend_tag)
async def create_backend(self, backend_tag, backend_config, func_or_class, actor_init_args): backend_config_dict = dict(backend_config) backend_worker = create_backend_worker(func_or_class) # Save creator which starts replicas. self.backend_table.register_backend(backend_tag, backend_worker) # Save information about configurations needed to start the replicas. self.backend_table.register_info(backend_tag, backend_config_dict) # Save the initial arguments needed by replicas. self.backend_table.save_init_args(backend_tag, actor_init_args) # Set the backend config inside the router # (particularly for max-batch-size). [router] = self.get_router() ray.get( router.set_backend_config.remote(backend_tag, backend_config_dict)) await self.scale_replicas(backend_tag, backend_config_dict["num_replicas"])
def __init__(self): self.worker = create_backend_worker(func_or_class)(name, name + ":tag", init_args, backend_config)
def __init__(self, router_handle): self.worker = create_backend_worker(func_or_class)( name, name + ":tag", init_args, router_handle=router_handle[0])