What is the correct way to access GlobalState info?

How severe does this issue affect your experience of using Ray?

  • Medium: It contributes to significant difficulty to complete my task, but I can work around it.

Under Ray 1.13.0 we currently have a custom Ray autoscaler that uses certain internal information from Ray’s GlobalState in order to make it’s scale-up/scale-down decisions. We are looking for the “right” way to access this data.

We do see in Ray 2.0.0 that this now has a DeprecationWarning attached so we are eager to fix this properly:

WARNING __init__.py:192 -- DeprecationWarning: `ray.state.GlobalState` is a private attribute and access will be removed in a future Ray version.

To be specific about what we are trying to extract from the Ray API, here are the components we are looking at and how we access the cluster information:

globalState = ray.state.GlobalState()
globalState._initialize_global_state(
    ray._raylet.GcsClientOptions.from_gcs_address(self.ray_address)
)
resourcesPerNode = globalState._available_resources_per_node()
actorTable = globalState.actor_table(None)
...

What the correct/public way to extract this information?

We recommend you to use this new API to access the cluster states.

https://docs.ray.io/en/master/ray-observability/state/state-api.html

You can also use ray status CLI to see the autoscaling status