How severe does this issue affect your experience of using Ray?
- Low: It annoys or frustrates me for a moment.
I’ve set up conditional decorators using the usual form:
def foo:
pass
if a:
foo_remote = ray.remote(foo)
else:
foo_remote = foo
but I’ve been unable to do the same thing with options like
@ray.remote(max_retries=10)
Can anyone point me to a way to use conditionals with arguments?
Many thanks!
I think you need to return the def for this to work ie:
To use conditionals with arguments in a decorator, you can define a function that returns the decorated function with the desired arguments. Here’s an example using ray.remote
:
def remote_decorator(a):
if a:
return ray.remote(max_retries=10)
else:
return ray.remote()
@remote_decorator(a=True)
def f():
pass
In this example, f
will be decorated with ray.remote(max_retries=10)
if a
is True
, and with ray.remote()
otherwise.
If this still doesn’t work can you cp in the error on execution and we can debug from there?
Thanks so much. makes complete sense!