ray: WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
What happened + What you expected to happen
I use ray in java. And I used JEP to call python in the remote method, but I got: WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
There is no problem with the current calculation results. Could you please tell me What are the hidden dangers?
I read the part of Java calling python in ray. It seems that there are some limitations, so we want to use JEP to implement Java calling python in ray. Will the above warnings affect the use?
Versions / Dependencies
jdk11 ubuntu20.0.4 maven ray2.0.0 python3.9.12
Reproduction script
public class RayDemo {
public static int square(int x) {
JepConfig config = new JepConfig();
config.addIncludePaths("/usr/local/mytest");
config.addIncludePaths(path);
SharedInterpreter.setConfig(config);
SharedInterpreter interp = new SharedInterpreter();
try{
interp.eval("from pydemo import *");
String res = interp.invoke("square",x).toString();
return Integer.valueOf(res);
}finally {
}
}
public static class Counter {
private int value = 0;
public void increment() {
SharedInterpreter interp = new SharedInterpreter();
try {
interp.eval("from pydemo import *");//python文件名 invoke
String res = interp.invoke("add",this.value).toString();
this.value= Integer.valueOf(res);
}finally {
}
}
public int read() {
return this.value;
}
}
public static void main(String[] args) {
// Intialize Ray runtime.
RayRuntimeFactory factory=new RayRuntimeFactory() {
@Override
public RayRuntime createRayRuntime() {
return null;
}
};
Ray.init();
{
List<ObjectRef<Integer>> objectRefList = new ArrayList<>();
// Invoke the `square` method 4 times remotely as Ray tasks.
// The tasks will run in parallel in the background.
for (int i = 0; i < 3; i++) {
objectRefList.add(Ray.task(RayDemo::square, i).remote());
}
// Get the actual results of the tasks with `get`.
System.out.println(Ray.get(objectRefList)); // [0, 1, 4, 9]
}
{
List<ActorHandle<Counter>> counters = new ArrayList<>();
// Create 4 actors from the `Counter` class.
// They will run in remote worker processes.
for (int i = 0; i < 6; i++) {
counters.add(Ray.actor(Counter::new).remote());
}
// Invoke the `increment` method on each actor.
// This will send an actor task to each remote actor.
for (ActorHandle<Counter> counter : counters) {
counter.task(Counter::increment).remote();
}
// Invoke the `read` method on each actor, and print the results.
List<ObjectRef<Integer>> objectRefList =
counters.stream()
.map(counter -> counter.task(Counter::read).remote())
.collect(Collectors.toList());
System.out.println(Ray.get(objectRefList)); // [1, 1, 1, 1]
}
{
try (Interpreter interp = new SharedInterpreter()) {
interp.eval("import numpy");
interp.eval("import sys");
interp.exec("from java.lang import System");//jep执行的python语句中可以引入java包
interp.exec("sys.s = 'Hello World'");
interp.exec("print(sys.s)");
//interp.exec("System.out.println(s)");
//interp.exec("print(s[1:-1])");
}
}
{
try (Interpreter interp = new SharedInterpreter()) {
interp.eval("import numpy");
interp.eval("import sys");
interp.exec("from java.lang import System");//jep执行的python语句中可以引入java包
//interp.exec("s = 'Hello World'");
interp.exec("print(sys.s)");
}
}
}
}
pydemo .py
def add(a):
return a + 1
def square(x):
return x * x
Issue Severity
No response
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 15 (9 by maintainers)
Add
Multi-Release: true
tomaven-assembly-plugin
: