Why can't ray.remote be used to decorate partial functions?

I noticed that it doesn’t seem to be possible to decorate partial functions with ray.remote (at least in ray 1.6.0):

import functools
import ray
ray.init()
def foo(x, y):
    return x+y
foo2 = ray.remote(foo)                                         # this works
result = ray.get([foo2.remote(x, y) for x, y in zip(range(5), range(5))])
foo3 = ray.remote(functools.partial(foo, y=1)) # this raises a TypeError

Is there some design reason as to why this is the case?

Hi @lebedov,

Welcome!

Try:

ray.get([functools.partial(ray.remote(foo).remote, y=1)(x=x) for x in range(5)]) 

Thanks, @mannyv - that works! Still curious why partial functions are disallowed - looking through the code in worker.py and actor.py, it seems to be due to more than just simple type checking to exclude arguments that are not functions or classes…

Thanks for this. Solves my same minded question