Package io.ray.api.function
Class PyFunction<R>
java.lang.Object
io.ray.api.function.PyFunction<R>
A class that represents a Python remote function.
example_package/
├──__init__.py
└──example_module.py
in example_module.py there is a function.
\@ray.remote
def bar(v):
return v
then we can call the Python function bar:
// bar returns input, so we have to set the returnType to int.class if bar accepts an int
ObjectRef<Integer> res = actor.call(
PyFunction.of("example_package.example_module", "bar", Integer.class),
1);
Integer value = res.get();
// bar returns input, so we have to set the returnType to String.class if bar accepts a string
ObjectRef<String> res = actor.call(
PyFunction.of("example_package.example_module", "bar", String.class),
"Hello world!");
String value = res.get();
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic PyFunction<Object>Create a python function.static <R> PyFunction<R>Create a python function.
-
Field Details
-
moduleName
-
functionName
-
returnType
-
-
Method Details
-
of
Create a python function.- Parameters:
moduleName- The full module name of this functionfunctionName- The name of this function- Returns:
- a python function.
-
of
Create a python function.- Type Parameters:
R- Type of the return value of this function- Parameters:
moduleName- The full module name of this functionfunctionName- The name of this functionreturnType- Class of the return value of this function- Returns:
- a python function.
-