mirror of
https://github.com/vale981/ray
synced 2025-03-06 10:31:39 -05:00
Update error message for @ray.method (#23471)
Updates @ray.method error message to match the one for @ray.remote. Since the client mode version of ray.method is identical to the regular ray.method, deletes the client mode version and drops the client_mode_hook decorator (guessing that the client copy was added before client_mode_hook was introduced). Also fixes what I'm guessing is a bug that doesn't allow both num_returns and concurrency_group to be specified at the same time (assert len(kwargs) == 1). Closes #23271
This commit is contained in:
parent
1c972d5d2d
commit
9b79048963
2 changed files with 26 additions and 8 deletions
|
@ -56,10 +56,19 @@ def method(*args, **kwargs):
|
|||
num_returns: The number of object refs that should be returned by
|
||||
invocations of this actor method.
|
||||
"""
|
||||
assert len(args) == 0
|
||||
assert len(kwargs) == 1
|
||||
|
||||
assert "num_returns" in kwargs or "concurrency_group" in kwargs
|
||||
valid_kwargs = ["num_returns", "concurrency_group"]
|
||||
error_string = (
|
||||
"The @ray.method decorator must be applied using at least one of "
|
||||
f"the arguments in the list {valid_kwargs}, for example "
|
||||
"'@ray.method(num_returns=2)'."
|
||||
)
|
||||
assert len(args) == 0 and len(kwargs) > 0, error_string
|
||||
for key in kwargs:
|
||||
key_error_string = (
|
||||
f"Unexpected keyword argument to @ray.method: '{key}'. The "
|
||||
f"supported keyword arguments are {valid_kwargs}"
|
||||
)
|
||||
assert key in valid_kwargs, key_error_string
|
||||
|
||||
def annotate_method(method):
|
||||
if "num_returns" in kwargs:
|
||||
|
|
|
@ -227,10 +227,19 @@ class ClientAPI:
|
|||
# activates the same logic on the server side; so there's no need to
|
||||
# pass anything else. It's inside the class definition that becomes an
|
||||
# actor. Similar annotations would follow the same way.
|
||||
assert len(args) == 0
|
||||
assert len(kwargs) == 1
|
||||
|
||||
assert "num_returns" in kwargs or "concurrency_group" in kwargs
|
||||
valid_kwargs = ["num_returns", "concurrency_group"]
|
||||
error_string = (
|
||||
"The @ray.method decorator must be applied using at least one of "
|
||||
f"the arguments in the list {valid_kwargs}, for example "
|
||||
"'@ray.method(num_returns=2)'."
|
||||
)
|
||||
assert len(args) == 0 and len(kwargs) > 0, error_string
|
||||
for key in kwargs:
|
||||
key_error_string = (
|
||||
f'Unexpected keyword argument to @ray.method: "{key}". The '
|
||||
f"supported keyword arguments are {valid_kwargs}"
|
||||
)
|
||||
assert key in valid_kwargs, key_error_string
|
||||
|
||||
def annotate_method(method):
|
||||
if "num_returns" in kwargs:
|
||||
|
|
Loading…
Add table
Reference in a new issue