Class PyActorMethod<R>

java.lang.Object
io.ray.api.function.PyActorMethod<R>

public class PyActorMethod<R> extends Object
A class that represents a method of a Python actor.

Note, information about the actor will be inferred from the actor handle, so it's not specified in this class.

 there is a Python actor class A.

 \@ray.remote
 class A(object):
     def foo(self):
         return "Hello world!"

 suppose we have got the Python actor class A's handle in Java

 
 PyActorHandle actor = ...; // returned from Ray.createActor or passed from Python
 

 then we can call the actor method:

 
 // A.foo returns a string, so we have to set the returnType to String.class
 ObjectRef<String> res = actor.call(PyActorMethod.of("foo", String.class));
 String x = res.get();
 
 
  • Field Details

    • methodName

      public final String methodName
    • returnType

      public final Class<R> returnType
  • Method Details

    • of

      public static PyActorMethod<Object> of(String methodName)
      Create a python actor method.
      Parameters:
      methodName - The name of this actor method
      Returns:
      a python actor method.
    • of

      public static <R> PyActorMethod<R> of(String methodName, Class<R> returnType)
      Create a python actor method.
      Type Parameters:
      R - The type of the return value of this actor method
      Parameters:
      methodName - The name of this actor method
      returnType - Class of the return value of this actor method
      Returns:
      a python actor method.