mirror of
https://github.com/wassname/ray.git
synced 2026-07-05 01:59:42 +08:00
[xlang] Cross language Python support (#6709)
This commit is contained in:
@@ -12,6 +12,25 @@ def py_func(value):
|
||||
return b"Response from Python: " + value
|
||||
|
||||
|
||||
@ray.remote
|
||||
def py_func_call_java_function(value):
|
||||
assert isinstance(value, bytes)
|
||||
f = ray.java_function("org.ray.api.test.CrossLanguageInvocationTest",
|
||||
"bytesEcho")
|
||||
r = f.remote(value)
|
||||
return b"[Python]py_func -> " + ray.get(r)
|
||||
|
||||
|
||||
@ray.remote
|
||||
def py_func_call_java_actor(value):
|
||||
assert isinstance(value, bytes)
|
||||
c = ray.java_actor_class(
|
||||
"org.ray.api.test.CrossLanguageInvocationTest$TestActor")
|
||||
java_actor = c.remote(b"Counter")
|
||||
r = java_actor.concat.remote(value)
|
||||
return ray.get(r)
|
||||
|
||||
|
||||
@ray.remote
|
||||
class Counter(object):
|
||||
def __init__(self, value):
|
||||
|
||||
Reference in New Issue
Block a user