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();
| 限定符和类型 | 字段和说明 |
|---|---|
String |
functionName |
String |
moduleName |
Class<R> |
returnType |
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 © 2021. All rights reserved.