Seems like the use of @property in actor class cannot be used with ray actor.
@ray.remote
class A:
def __init__(self,x):
self.x = x
@property
def x_square(self):
return x**2
a_instance = a.remote(x=5)
ray.get(a_instance.x_square.remote())

If we cannot run your script, we cannot fix your issue.
cc @ericl
I think it is an expected behavior because you cannot access the member variables of actors with a remote call. Afaik, @property makes a class member variables that are aliases to getter and setter, so it is expected that it doesn't work.
If this is a hard requirement, please create a feature request! I will close it for now.
I am running into this issue. I have a class that has several @property methods. I have found myself working around this by creating a derived "ray" class and creating getter and setter methods for all the properties. Quite verbose and ugly I must say. Here's what the derived class looks like:
@ray.remote
class PhyloTreeLikelihoodMoverActor(PhyloTreeLikelihoodMover):
def set_seed(self, seed):
self.prng.seed(seed)
def get_attachment_log_like(self):
return self.attachment_log_like
def get_has_changed_nodes(self):
return self.has_changed_nodes
def get_double_check_ll_calculations(self):
return self.double_check_ll_calculations
def set_double_check_ll_calculations(self, val):
self.double_check_ll_calculations = val
def get_check_logsumexp_accuracy(self):
return self.check_logsumexp_accuracy
def set_check_logsumexp_accuracy(self, val):
self.check_logsumexp_accuracy = val
def get_logsumexp_refresh_rate(self):
return self.logsumexp_refresh_rate
def set_logsumexp_refresh_rate(self, val):
self.logsumexp_refresh_rate = val
def get_g(self):
return self.g
def get_mh_correction(self):
return self.mover.mh_correction
As far as I can tell, only the first method would be needed otherwise. I would also be happy to hear suggestions on how to rationalize code.
However, this is still way better than any other library I have tried...
Hmm, this is an interesting issue. I'm not sure it's possible in general to generate all possible attribute accessors so that they can be called with .remote(). For example, a class might define __getattribute__ to return computed attribute values.
As a workaround, you could probably define a method like this:
def getattr(self, attr):
return getattr(self, attr)
Then on the actor you can actor.getattr.remote("attachment_log_like") to dynamically get the attribute.
Nice! That worked for me!