I have a ray cluster running on a machine as below:
ray start --head --redis-port=6379
I have two files that need to run on the cluster. Producer p_ray.py:
import ray
ray.init(address='auto', redis_password='5241590000000000')
@ray.remote
class Counter(object):
def __init__(self):
self.n = 0
def increment(self):
self.n += 1
def read(self):
return self.n
counters = [Counter.remote() for i in range(4)]
[c.increment.remote() for c in counters]
futures = [c.read.remote() for c in counters]
print(futures, type(futures[0]))
obj_id = ray.put(ray.get(futures))
print(obj_id)
print(ray.get(obj_id))
while True:
pass
Consumer c_ray.py:
import ray
ray.init(address='auto', redis_password='5241590000000000')
[objs] = ray.objects()
print('OBJ-ID:', objs, 'TYPE:', type(objs))
print(ray.get([objs]))
My intention is to store the futures objects from producer and retrieve it in the consumer. I can retrieve the Object ID in the consumer. However the get in the consumer never returns.
What am I doing wrong?
How do I resolve my requirement?