I am new to Ray and am seeing some behavior I didn’t expect.
I would like to understand how Ray handles passing obj references to remote functions.
Say I have a class “E”, which I instantiate as ‘obj’.
I pass obj to a remote function ‘func_1’, which does something, but it is (unexpectedly) doing it on a copy of the original obj.
I expected each remote Ray function call to operate on the passed object reference directly, but it is creating a new object and operating on that instead.
Is there a way to get the remote function to act on the original object reference and not a copy?
@ray.remote def func_1(obj): #obj is an class obj ref = obj.doSomething() return obj class E(object): def init(self): return def doSomething(self): return def main(): objs =  future =  for _ in range(5): obj = E() objs.append(obj) print("Original: " + str(obj)) future.append(func_1.remote(obj)) obj2 = ray.get(future) [print("New: " + str(o)) for o in obj2] return if __name__ == "__main__": main()
Original: <main.E object at 0x7f26cc111ca0>
Original: <main.E object at 0x7f26bc13d730>
Original: <main.E object at 0x7f26cc0e2c70>
Original: <main.E object at 0x7f269c5a5520>
Original: <main.E object at 0x7f26bc100520>
New: <main.E object at 0x7f26bc100640>
New: <main.E object at 0x7f26bc13deb0>
New: <main.E object at 0x7f26bc100460>
New: <main.E object at 0x7f26bc100220>
New: <main.E object at 0x7f26bc1008b0>