from functools import wraps
import ray
ray.init()
def say_hey(func):
@wraps(func)
def wrapper(*args, **kwargs):
print('hey')
return func(*args, **kwargs)
return wrapper
@say_hey
@ray.remote
def print_hello():
print('hellooo')
print_hello.remote()
can someone explain why the output is:
hellooo
instead of raising TypeError: Remote functions cannot be called directly. Instead of running '__main__.print_hello()', try '__main__.print_hello.remote()'.
?
this is what I believe happens, in order:
- the
print_hello
function is defined -
print_hello
becomes aRemoteFunction
- the
RemoteFunction
becomes decorated bysay_hey
so when print_hello
is called, say_hey
should print hey
and then try to call func
, which is a RemoteFunction
, which should raise an error