Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class attribute in ray actor cannot be accessed/copied #11959

Open
2 tasks done
jiangtianli91 opened this issue Nov 12, 2020 · 22 comments
Open
2 tasks done

Class attribute in ray actor cannot be accessed/copied #11959

jiangtianli91 opened this issue Nov 12, 2020 · 22 comments
Labels
api-bug Bug in which APIs behavior is wrong bug Something that is supposed to be working; but isn't core Issues that should be addressed in Ray Core core-api P1.5 Issues that will be fixed in a couple releases. It will be bumped once all P1s are cleared size:medium usability
Milestone

Comments

@jiangtianli91
Copy link

jiangtianli91 commented Nov 12, 2020

What is the problem?

Ray actor fails to access class attributes.

Ray version and other system information (Python version, TensorFlow version, OS):
ray 1.0.0
Python 3.7.7

Reproduction (REQUIRED)

This code is modified from dask/distributed#4233 (comment)

from module import Foo
import ray

@ray.remote
class ray_Foo:
    def __init__(self, Foo):
        self.Foo = Foo

    def show(self):
        return self.Foo.bar


ray.init()
foo = Foo()
foo.append(123)
print(foo.show())

ray_foo = ray_Foo.remote(foo)
print(ray.get(ray_foo.show.remote()))
$ cat module.py
class Foo:
    bar = []

    def append(self, value):
        self.bar.append(value)

    def show(self):
        return self.bar

$ python ray_issue_new.py
[123]
[]

If we cannot run your script, we cannot fix your issue.

  • I have verified my script runs in a clean environment and reproduces the issue.
  • I have verified the issue also occurs with the latest wheels.
@jiangtianli91 jiangtianli91 added bug Something that is supposed to be working; but isn't triage Needs triage (eg: priority, bug/not-bug, and owning component) labels Nov 12, 2020
@rkooo567 rkooo567 added the core label Nov 12, 2020
@rkooo567
Copy link
Contributor

rkooo567 commented Nov 12, 2020

This is an interesting issue. It seems like it only happens when we send serialized objects to other processes.

from module import Foo
import ray

@ray.remote
class ray_Foo:
    def __init__(self, Foo):
        self.Foo = Foo

    def show(self):
        return self.Foo.bar

@ray.remote
def f(foo):
    return foo.bar

ray.init()
foo = Foo()
foo.append(123)
print(foo.show())
p = ray.put(foo)
print(ray.get(p).bar)
ray_foo = ray_Foo.remote(foo)
print(ray.get(f.remote(p)))
print(ray.get(ray_foo.show.remote()))

As you can see

p = ray.put(foo)
print(ray.get(p).bar)

works, but it doesn't work only when objects are sent to other processes.

@rkooo567
Copy link
Contributor

cc @robertnishihara Have you seen similar issues before?

@rkooo567
Copy link
Contributor

Also @richardliaw

@wuisawesome
Copy link
Contributor

Since this seems to be a pickling issue, I wonder if we should first try to reproduce the issue with just cloudpickle and forward this to their team.

@rkooo567
Copy link
Contributor

@wuisawesome That sounds like a good idea. @jiangtianli91 Does this issue block you, or is it something that you can get around? (a.k.a, is it possible to not use class attributes? I assume this can be a blocker if this happens from other libraries that you depend on)

@jiangtianli91
Copy link
Author

@wuisawesome That sounds like a good idea. @jiangtianli91 Does this issue block you, or is it something that you can get around? (a.k.a, is it possible to not use class attributes? I assume this can be a blocker if this happens from other libraries that you depend on)

So far we have hit this issue because our own libraries used class attributes, so we could move those although it does disrupt the organization a bit.

@rkooo567
Copy link
Contributor

Gotcha. Btw, @suquark Have you seen any similar issue before?

@ericl ericl added P2 Important issue, but not time-critical and removed triage Needs triage (eg: priority, bug/not-bug, and owning component) labels Dec 8, 2020
@ericl ericl removed the core label Jan 20, 2021
@jenny-hm-lee
Copy link

I have this issue.

@jenny-hm-lee
Copy link

Have this issues been resolved in latest version of Ray?

@jiangtianli91
Copy link
Author

@rkooo567 @wuisawesome Hello, it seems that cloudpickle has merged a pull request (here) that can solve this issue. I wonder whether it can be implemented here?

@mbwmbw1337
Copy link

We're seeing the same issue. What is the best workaround or have you been converting all class attributes to instances?

@mbwmbw1337
Copy link

Have this issues been resolved in latest version of Ray?

Not resolved as far as I am able to tell.

@jiangtianli91
Copy link
Author

@rkooo567 Hello, I wonder is there any plan to fix this bug?

@rkooo567
Copy link
Contributor

Hmm, if this is correct #11959 (comment), using the latest cloudpickle should fix the issue? Have we merged the upstream cloudpickle? cc @suquark

@filip-halt
Copy link

I am also having this issue, sending an object to an actor causes it to lose its attributes.

@clarkzinzow
Copy link
Contributor

@suquark Do you know if that upstream fix was merged?

@qmihau
Copy link

qmihau commented Aug 5, 2022

Hi, I'm having that issue in ray 1.13.0 with cloudpickle 2.1.0. Is there any chance it will be resolved fairly soon?

@rkooo567
Copy link
Contributor

rkooo567 commented Aug 5, 2022

Let us revisit this soon. Will bump up the priority.

@rkooo567 rkooo567 added P1 Issue that should be fixed within a few weeks usability and removed P2 Important issue, but not time-critical labels Aug 5, 2022
@rkooo567 rkooo567 added this to the Core Backlog milestone Aug 5, 2022
@qmihau
Copy link

qmihau commented Aug 5, 2022

Thanks! Happy to help test or if you'll need any extra information.

@qmihau
Copy link

qmihau commented Sep 8, 2022

@rkooo567 Do you have a feel for when that might get into the work pipeline? Definitely don't want to be pushy, but just trying to plan our work accordingly :)

@rkooo567
Copy link
Contributor

rkooo567 commented Dec 8, 2022

I think it is hard to guarantee the specific timeline for the fix. We are planning to take a look, but there are plenty of other issues, and this is currently not the highest priority.

@rkooo567 rkooo567 added Ray 2.5 and removed Ray 2.4 labels Feb 20, 2023
@rkooo567 rkooo567 added the api-bug Bug in which APIs behavior is wrong label Mar 24, 2023
@rkooo567 rkooo567 added P1.5 Issues that will be fixed in a couple releases. It will be bumped once all P1s are cleared and removed P1 Issue that should be fixed within a few weeks Ray 2.5 labels Apr 7, 2023
@thomasbbrunner
Copy link

thomasbbrunner commented Sep 11, 2023

Can confirm that this is still an issue in Ray 2.6.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-bug Bug in which APIs behavior is wrong bug Something that is supposed to be working; but isn't core Issues that should be addressed in Ray Core core-api P1.5 Issues that will be fixed in a couple releases. It will be bumped once all P1s are cleared size:medium usability
Projects
None yet
Development

No branches or pull requests