Non python ray and multi language

I see there is also a Java and an experimental c++ API. I see example of code where the same script is built in each of these languages, but what if I want one script made with python to call a remote which is only implemented in Java or C++, is that possible? Was browsing the documentation but could not get that

cc @ffbin Can you address this question?

@delioda79 Currently you can make a remote call to a remote java function or a remote java actor method in python. c++ support is in the progress.
In order to do that, you need ensure the jars that contains the java functions is on the code search path. You can setup code search path by following the doc Cross-language programming — Ray v1.1.0. Then you can make a java function call by first creatign the java function reference and then make the call:

# Define a Java function.
add_function = ray.java_function(
      "io.ray.demo.Math", "add")

# Call the Java remote function.
obj_ref3 = add_function.remote(1, 2)
assert ray.get(obj_ref3) == 3

Currently we only support automatic numeric types/string/binary/bool serialization between java and python workers. If you need to have more complicated serialization support, you may need to use protobuf.

Thanks for the reply, this however makes me think if two more questions on the subject:

  1. When you say about using protobuf, is there any existing mechanism to include it in ray? Cannot find in the docs, or do you mean to just accept an array of bytes in the function signature and then use protobuf (or greenpack or even just json) for serialisation/deserialisation?

  2. Is there any way we can implement a way to add other languages to ray? Say I want to use Go or Rust, maybe I could contribute

  1. There’s no built-in mechanism to use protobuf. I think what he meant is to write your payload to the protobuf, serialize them to bytes and deserialize in the other language worker.

Regarding 2, All of ray workers have a cpp backend called core_worker. How you implement the frontend is to use core worker APIs to communicate to core ray. Unfortunately, this interface is not that well defined & explained (so the only way you can do is to look at other implementation like cpp, java, or python).

I remember @barakmich has an idea to do this in an easier way, but I have not much context. You can probably follow up with him.