mirror of
https://github.com/vale981/ray
synced 2025-03-06 10:31:39 -05:00
Fix bug when failing to import remote functions or actors with args and kwargs. (#6577)
This commit is contained in:
parent
687de41273
commit
2f57391595
2 changed files with 12 additions and 11 deletions
|
@ -390,7 +390,7 @@ class FunctionActorManager(object):
|
|||
|
||||
# This is a placeholder in case the function can't be unpickled. This
|
||||
# will be overwritten if the function is successfully registered.
|
||||
def f():
|
||||
def f(*args, **kwargs):
|
||||
raise Exception("This function was not imported properly.")
|
||||
|
||||
# This function is called by ImportThread. This operation needs to be
|
||||
|
@ -664,7 +664,7 @@ class FunctionActorManager(object):
|
|||
class TemporaryActor(object):
|
||||
pass
|
||||
|
||||
def temporary_actor_method(*xs):
|
||||
def temporary_actor_method(*args, **kwargs):
|
||||
raise Exception(
|
||||
"The actor with name {} failed to be imported, "
|
||||
"and so cannot execute this method.".format(actor_class_name))
|
||||
|
|
|
@ -104,7 +104,7 @@ def temporary_helper_function():
|
|||
# Define a function that closes over this temporary module. This should
|
||||
# fail when it is unpickled.
|
||||
@ray.remote
|
||||
def g():
|
||||
def g(x, y=3):
|
||||
try:
|
||||
module.temporary_python_file()
|
||||
except Exception:
|
||||
|
@ -113,7 +113,7 @@ def temporary_helper_function():
|
|||
pass
|
||||
|
||||
# Invoke the function so that the definition is exported.
|
||||
g.remote()
|
||||
g.remote(1, y=2)
|
||||
|
||||
wait_for_errors(ray_constants.REGISTER_REMOTE_FUNCTION_PUSH_ERROR, 2)
|
||||
errors = relevant_errors(ray_constants.REGISTER_REMOTE_FUNCTION_PUSH_ERROR)
|
||||
|
@ -124,8 +124,9 @@ def temporary_helper_function():
|
|||
# Check that if we try to call the function it throws an exception and
|
||||
# does not hang.
|
||||
for _ in range(10):
|
||||
with pytest.raises(Exception):
|
||||
ray.get(g.remote())
|
||||
with pytest.raises(
|
||||
Exception, match="This function was not imported properly."):
|
||||
ray.get(g.remote(1, y=2))
|
||||
|
||||
f.close()
|
||||
|
||||
|
@ -167,17 +168,17 @@ def temporary_helper_function():
|
|||
# fail when it is unpickled.
|
||||
@ray.remote
|
||||
class Foo(object):
|
||||
def __init__(self):
|
||||
def __init__(self, arg1, arg2=3):
|
||||
self.x = module.temporary_python_file()
|
||||
|
||||
def get_val(self):
|
||||
def get_val(self, arg1, arg2=3):
|
||||
return 1
|
||||
|
||||
# There should be no errors yet.
|
||||
assert len(ray.errors()) == 0
|
||||
|
||||
# Create an actor.
|
||||
foo = Foo.remote()
|
||||
foo = Foo.remote(3, arg2=0)
|
||||
|
||||
# Wait for the error to arrive.
|
||||
wait_for_errors(ray_constants.REGISTER_ACTOR_PUSH_ERROR, 1)
|
||||
|
@ -192,8 +193,8 @@ def temporary_helper_function():
|
|||
|
||||
# Check that if we try to get the function it throws an exception and
|
||||
# does not hang.
|
||||
with pytest.raises(Exception):
|
||||
ray.get(foo.get_val.remote())
|
||||
with pytest.raises(Exception, match="failed to be imported"):
|
||||
ray.get(foo.get_val.remote(1, arg2=2))
|
||||
|
||||
# Wait for the error from when the call to get_val.
|
||||
wait_for_errors(ray_constants.TASK_PUSH_ERROR, 2)
|
||||
|
|
Loading…
Add table
Reference in a new issue