Hi, I have a question about accessing attribute on ray actors. In order to access an attribute on an actor, you need to create a method for that like that get_counter in the following example.
import ray
@ray.remote
class Counter:
def __init__(self):
self.value = 0
def increment(self):
self.value += 1
return self.value
def get_counter(self):
return self.value
# Create an actor from this class.
counter = Counter.remote()
However my use case is this, I want to get an attribute on an arg that is passed to my class, any idea why this is not working?
# my_module.py
@ray.remote
class MyClass:
def __init__(self, dependent: DependentClass):
self.dependent = dependent
def update_dependent(self):
self.dependent.attribute = 5
def get_dependent_attribute(self):
return self.dependent.attribute
And in the my driver script:
from my_module import MyClass, DependentClass
my_remote_class = MyClass(dependent=DependentClass())
result_ref = my_remote_class.update_dependent.remote()
ray.get(result_ref)
attribute_ref = my_remote_class.get_dependent_attribute.remote()
attribute = ray.get(attribute_ref)
print(attribute) # The attribute is not updated