def _ray_from_modified_class(cls, modified_class, class_id, max_restarts, num_cpus, num_gpus, memory, object_store_memory, resources): for attribute in [ "remote", "_remote", "_ray_from_modified_class", "_ray_from_function_descriptor" ]: if hasattr(modified_class, attribute): logger.warning("Creating an actor from class {} overwrites " "attribute {} of that class".format( modified_class.__name__, attribute)) # Make sure the actor class we are constructing inherits from the # original class so it retains all class properties. class DerivedActorClass(cls, modified_class): pass name = "ActorClass({})".format(modified_class.__name__) DerivedActorClass.__module__ = modified_class.__module__ DerivedActorClass.__name__ = name DerivedActorClass.__qualname__ = name # Construct the base object. self = DerivedActorClass.__new__(DerivedActorClass) # Actor creation function descriptor. actor_creation_function_descriptor = \ PythonFunctionDescriptor.from_class( modified_class.__ray_actor_class__) self.__ray_metadata__ = ActorClassMetadata( Language.PYTHON, modified_class, actor_creation_function_descriptor, class_id, max_restarts, num_cpus, num_gpus, memory, object_store_memory, resources) return self
def _ray_from_modified_class(cls, modified_class, class_id, max_restarts, max_task_retries, num_cpus, num_gpus, memory, object_store_memory, resources, accelerator_type, runtime_env, concurrency_groups): for attribute in [ "remote", "_remote", "_ray_from_modified_class", "_ray_from_function_descriptor", ]: if hasattr(modified_class, attribute): logger.warning("Creating an actor from class " f"{modified_class.__name__} overwrites " f"attribute {attribute} of that class") # Make sure the actor class we are constructing inherits from the # original class so it retains all class properties. class DerivedActorClass(cls, modified_class): pass name = f"ActorClass({modified_class.__name__})" DerivedActorClass.__module__ = modified_class.__module__ DerivedActorClass.__name__ = name DerivedActorClass.__qualname__ = name # Construct the base object. self = DerivedActorClass.__new__(DerivedActorClass) # Actor creation function descriptor. actor_creation_function_descriptor = \ PythonFunctionDescriptor.from_class( modified_class.__ray_actor_class__) # Parse local pip/conda config files here. If we instead did it in # .remote(), it would get run in the Ray Client server, which runs on # a remote node where the files aren't available. if runtime_env: if isinstance(runtime_env, str): new_runtime_env = runtime_env else: new_runtime_env = ParsedRuntimeEnv(runtime_env).serialize() else: new_runtime_env = None self.__ray_metadata__ = ActorClassMetadata( Language.PYTHON, modified_class, actor_creation_function_descriptor, class_id, max_restarts, max_task_retries, num_cpus, num_gpus, memory, object_store_memory, resources, accelerator_type, new_runtime_env, concurrency_groups) return self