public class PyFunction<R> extends Object
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();
| Modifier and Type | Field and Description |
|---|---|
String |
functionName |
String |
moduleName |
Class<R> |
returnType |
| Modifier and Type | Method and Description |
|---|---|
static PyFunction<Object> |
of(String moduleName,
String functionName)
Create a python function.
|
static <R> PyFunction<R> |
of(String moduleName,
String functionName,
Class<R> returnType)
Create a python function.
|
public final String moduleName
public final String functionName
public static PyFunction<Object> of(String moduleName, String functionName)
moduleName - The full module name of this functionfunctionName - The name of this functionpublic static <R> PyFunction<R> of(String moduleName, String functionName, Class<R> returnType)
R - Type of the return value of this functionmoduleName - The full module name of this functionfunctionName - The name of this functionreturnType - Class of the return value of this functionCopyright © 2024. All rights reserved.