import ray
ray.init()
class Test:
def __init__(self):
pass
actor = ray.remote(Test, num_cpus=1).remote()
fails with
AssertionError: The @ray.remote decorator must be applied either with no arguments and no parentheses, for example '@ray.remote', or it must be applied using some of the arguments 'num_return_vals', 'num_cpus', 'num_gpus', 'memory', 'object_store_memory', 'resources', 'max_calls', or 'max_reconstructions', like '@ray.remote(num_return_vals=2, resources={"CustomResource": 1})'.
Doing the same thing with a decorator (@ray.remote(num_cpus=1)) works, but I want to be able to use classes with and without Ray (eg for unit tests), so I don't want to use decorators.
Try:
actor = ray.remote(num_cpus=1)(Test).remote()
# is equivalent to:
RemoteTestClass = ray.remote(num_cpus=1)(Test)
actor = RemoteTestClass.remote()
Gotcha, that works. The example in the docs is
Counter = ray.remote(Counter)
which is how I got to my approach. Perhaps another example could be provided with your method?
Hi, I'm a bot from the Ray team :)
To help human contributors to focus on more relevant issues, I will automatically add the stale label to issues that have had no activity for more than 4 months.
If there is no further activity in the 14 days, the issue will be closed!
You can always ask for help on our discussion forum or Ray's public slack channel.