Skip to content

Instantly share code, notes, and snippets.

@edoakes
Created February 24, 2021 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edoakes/9cbdc271b74609f6c2e4192aee9bae3f to your computer and use it in GitHub Desktop.
Save edoakes/9cbdc271b74609f6c2e4192aee9bae3f to your computer and use it in GitHub Desktop.
ray.init()
@ray.remote
class Controller:
def start_me_an_actor(self, cls):
# Start an actor on behalf of the caller.
ray.remote(cls).remote()
Controller.options(name="controller", lifetime="detached").remote()
# The below can happen in a new driver program.
ray.init(working_dir=".")
class MyNewActor:
pass
# The user probably wants the working_dir to be set properly here, but
# it won't because the controller was run in a different job.
controller = ray.get_actor("controller")
controller.start_me_an_actor.remote(MyNewActor)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment