Is it possible to expose Actors from client process?

After connecting to an existing Ray cluster with ray.init, is it possible to create and expose an Actor from the same process that called ray.init, i.e. not in a dedicated worker process?

I’m asking because I’d like to expose a Ray Actor from within the terminal of an external GUI application.

Thanks for any leads.

To be clear, are you asking if it is possible to create an actor within a driver? (the script that calls ray.init())?

Yes, that’s correct. I’d like to know whether there is a feasible way to connect to an existing cluster with ray.init and then create an Actor in the same script / terminal.

IIUC actors always start in a new process, including on a local machine. Do you want to expose the Actor’s stdin, or another interface?

I’d like the Actor to run inside another application so that I can utilize this application through the ray cluster.

Currently, I can interact with the ray cluster from within the application by using ray.init etc.

Instead of that, I’d like to expose an Actor or Serve Deployment from within the application, to allow interacting with it remotely. It would be fine if the Actor runs inside a new process, but I need to be able to interact with this process to connect the methods of the Actor/Deployment to the appropriate functions of the external application.

Edit: The application is a GUI app, so I can’t run it just anywhere. Also, the easiest way to integrate a ray Actor with the UI event loop is to run it from within.

Edit2: Basically, what I’m asking is how do I start a ray worker manually, from within a Python interpreter, in a way that allows subsequent interaction with its process.

Nevermind, I should probably just go with gRPC directly.

If the GUI application can run Python, maybe consider using Ray client: Ray Client — Ray v1.8.0? It serves the purpose of interacting with a Ray cluster, from outside of the Ray cluster. You can create actors and call actor methods from the Ray client. GRPC definitely works too but might be more complicated than using Ray client.

Perhaps I don’t understand you correctly @Mingwei, but this sounds like what I already have. Instead, I’d like to use the ray cluster to remotely interact with an Actor running inside the GUI application.

I see. I thought the goal is to use GUI application to control the Ray cluster, but it seems the goal is the other way: Ray cluster runs an actor wrapping the GUI application. I don’t have a better suggestion right now.