ray-project / ray

Ray is an AI compute engine. Ray consists of a core distributed runtime and a set of AI Libraries for accelerating ML workloads.
https://ray.io
Apache License 2.0
33.88k stars 5.76k forks source link

[Core] AttributeError: module 'ray.util' has no attribute 'state' #48656

Open miguelteixeiraa opened 5 hours ago

miguelteixeiraa commented 5 hours ago

What happened + What you expected to happen

I can't use the StateAPI. Are these alpha APIs expected to be available on Windows and Mac? When I try to use it I get the following error (on Mac -- did not test on Windows):

AttributeError: module 'ray.util' has no attribute 'state'

Versions / Dependencies

OS: macOS Sonoma 14.6 Python: 3.11.9 ray-2.38.0

Reproduction script

from time import sleep
import ray

ray.init()

@ray.remote
class CounterActor:
    def __init__(self):
        self._counter = 0

    def run(self):
        while True:
            sleep(1)
            self._counter += 1
            print(self._counter)

counter = CounterActor.options(name="named-actor").remote()
counter.run.remote()

while True:
    sleep(1)
    actors_list = ray.util.state.list_actors()
    print(actors_list)
 line 25, in <module>
    actors_list = ray.util.state.list_actors()
                  ^^^^^^^^^^^^^^
AttributeError: module 'ray.util' has no attribute 'state'

Issue Severity

High: It blocks me from completing my task.

Superskyyy commented 3 hours ago

You should do from ray.util import state or from ray.util.state import get_actor, list_actors