def test_cross_language_raise_kwargs(shutdown_only):
    ray.init(job_config=ray.job_config.JobConfig(code_search_path=sys.path))

    with pytest.raises(Exception, match="kwargs"):
        ray.java_function("a", "b").remote(x="arg1")

    with pytest.raises(Exception, match="kwargs"):
        ray.java_actor_class("a").remote(x="arg1")
def test_cross_language_raise_exception(shutdown_only):
    ray.init(job_config=ray.job_config.JobConfig(code_search_path=sys.path))

    class PythonObject(object):
        pass

    with pytest.raises(Exception, match="transfer"):
        ray.java_function("a", "b").remote(PythonObject())
Exemple #3
0
def test_cross_language_raise_kwargs(shutdown_only):
    ray.init(_load_code_from_local=True, _include_java=True)

    with pytest.raises(Exception, match="kwargs"):
        ray.java_function("a", "b").remote(x="arg1")

    with pytest.raises(Exception, match="kwargs"):
        ray.java_actor_class("a").remote(x="arg1")
Exemple #4
0
def test_cross_language_raise_exception(shutdown_only):
    ray.init(_load_code_from_local=True, _include_java=True)

    class PythonObject(object):
        pass

    with pytest.raises(Exception, match="transfer"):
        ray.java_function("a", "b").remote(PythonObject())
Exemple #5
0
def py_func_pass_python_actor_handle():
    counter = Counter.remote(2)
    f = ray.java_function(
        "io.ray.test.CrossLanguageInvocationTest", "callPythonActorHandle"
    )
    r = f.remote(counter)
    return ray.get(r)
Exemple #6
0
def py_func_call_java_function():
    try:
        # None
        r = ray.java_function(
            "io.ray.test.CrossLanguageInvocationTest", "returnInput"
        ).remote(None)
        assert ray.get(r) is None
        # bool
        r = ray.java_function(
            "io.ray.test.CrossLanguageInvocationTest", "returnInputBoolean"
        ).remote(True)
        assert ray.get(r) is True
        # int
        r = ray.java_function(
            "io.ray.test.CrossLanguageInvocationTest", "returnInputInt"
        ).remote(100)
        assert ray.get(r) == 100
        # double
        r = ray.java_function(
            "io.ray.test.CrossLanguageInvocationTest", "returnInputDouble"
        ).remote(1.23)
        assert ray.get(r) == 1.23
        # string
        r = ray.java_function(
            "io.ray.test.CrossLanguageInvocationTest", "returnInputString"
        ).remote("Hello World!")
        assert ray.get(r) == "Hello World!"
        # list (tuple will be packed by pickle,
        # so only list can be transferred across language)
        r = ray.java_function(
            "io.ray.test.CrossLanguageInvocationTest", "returnInputIntArray"
        ).remote([1, 2, 3])
        assert ray.get(r) == [1, 2, 3]
        # pack
        f = ray.java_function("io.ray.test.CrossLanguageInvocationTest", "pack")
        input = [100, "hello", 1.23, [1, "2", 3.0]]
        r = f.remote(*input)
        assert ray.get(r) == input
        return "success"
    except Exception as ex:
        return str(ex)
def py_func_nest_python_raise_exception():
    f = ray.java_function("io.ray.test.CrossLanguageInvocationTest",
                          "raisePythonException")
    r = f.remote()
    return ray.get(r)
def py_func_java_throw_exception():
    f = ray.java_function("io.ray.test.CrossLanguageInvocationTest",
                          "throwException")
    r = f.remote()
    return ray.get(r)
def py_func_pass_python_actor_handle():
    counter = Counter.remote(2)
    f = ray.java_function("org.ray.api.test.CrossLanguageInvocationTest",
                          "callPythonActorHandle")
    r = f.remote(counter._serialization_helper()[0])
    return ray.get(r)
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)