Skip to content

Commit

Permalink
Move global state API out of global_state object. (ray-project#4857)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertnishihara authored and pcmoritz committed May 26, 2019
1 parent ea8d7b4 commit 6703519
Show file tree
Hide file tree
Showing 29 changed files with 387 additions and 403 deletions.
4 changes: 2 additions & 2 deletions ci/stress_tests/test_many_tasks_and_transfers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@

# Wait until the expected number of nodes have joined the cluster.
while True:
if len(ray.global_state.client_table()) >= num_remote_nodes + 1:
if len(ray.nodes()) >= num_remote_nodes + 1:
break
logger.info("Nodes have all joined. There are %s resources.",
ray.global_state.cluster_resources())
ray.cluster_resources())


# Require 1 GPU to force the tasks to be on remote machines.
Expand Down
20 changes: 20 additions & 0 deletions doc/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,26 @@ The Ray API

.. autofunction:: ray.method

Inspect the Cluster State
-------------------------

.. autofunction:: ray.nodes()

.. autofunction:: ray.tasks()

.. autofunction:: ray.objects()

.. autofunction:: ray.timeline()

.. autofunction:: ray.object_transfer_timeline()

.. autofunction:: ray.cluster_resources()

.. autofunction:: ray.available_resources()

.. autofunction:: ray.errors()


The Ray Command Line API
------------------------

Expand Down
10 changes: 5 additions & 5 deletions doc/source/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Python script with the following:
.. code-block:: bash
RAY_RAYLET_GDB=1 RAY_RAYLET_TMUX=1 python
You can then list the ``tmux`` sessions with ``tmux ls`` and attach to the
appropriate one.

Expand All @@ -71,14 +71,14 @@ allow core dump files to be written.

Inspecting Redis shards
~~~~~~~~~~~~~~~~~~~~~~~
To inspect Redis, you can use the ``ray.experimental.state.GlobalState`` Python
API. The easiest way to do this is to start or connect to a Ray cluster with
``ray.init()``, then query the API like so:
To inspect Redis, you can use the global state API. The easiest way to do this
is to start or connect to a Ray cluster with ``ray.init()``, then query the API
like so:

.. code-block:: python
ray.init()
ray.worker.global_state.client_table()
ray.nodes()
# Returns current information about the nodes in the cluster, such as:
# [{'ClientID': '2a9d2b34ad24a37ed54e4fcd32bf19f915742f5b',
# 'EntryType': 0,
Expand Down
2 changes: 1 addition & 1 deletion doc/source/user-profiling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ following command.

.. code-block:: python
ray.global_state.chrome_tracing_dump(filename="/tmp/timeline.json")
ray.timeline(filename="/tmp/timeline.json")
Then open `chrome://tracing`_ in the Chrome web browser, and load
``timeline.json``.
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# Wait for all 4 nodes to join the cluster.
while True:
num_nodes = len(ray.global_state.client_table())
num_nodes = len(ray.nodes())
if num_nodes < 4:
print("{} nodes have joined so far. Waiting for more."
.format(num_nodes))
Expand Down
16 changes: 12 additions & 4 deletions python/ray/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,20 @@
_config = _Config()

from ray.profiling import profile # noqa: E402
from ray.state import (global_state, nodes, tasks, objects, timeline,
object_transfer_timeline, cluster_resources,
available_resources, errors) # noqa: E402
from ray.worker import (
LOCAL_MODE,
PYTHON_MODE,
SCRIPT_MODE,
WORKER_MODE,
connect,
disconnect,
error_info,
get,
get_gpu_ids,
get_resource_ids,
get_webui_url,
global_state,
init,
is_initialized,
put,
Expand All @@ -98,6 +99,15 @@
__version__ = "0.8.0.dev0"

__all__ = [
"global_state",
"nodes",
"tasks",
"objects",
"timeline",
"object_transfer_timeline",
"cluster_resources",
"available_resources",
"errors",
"LOCAL_MODE",
"PYTHON_MODE",
"SCRIPT_MODE",
Expand All @@ -108,12 +118,10 @@
"actor",
"connect",
"disconnect",
"error_info",
"get",
"get_gpu_ids",
"get_resource_ids",
"get_webui_url",
"global_state",
"init",
"internal",
"is_initialized",
Expand Down
4 changes: 2 additions & 2 deletions python/ray/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ def exit_actor():
worker.raylet_client.disconnect()
ray.disconnect()
# Disconnect global state from GCS.
ray.global_state.disconnect()
ray.state.state.disconnect()
sys.exit(0)
assert False, "This process should have terminated."
else:
Expand Down Expand Up @@ -931,7 +931,7 @@ def get_checkpoints_for_actor(actor_id):
"""Get the available checkpoints for the given actor ID, return a list
sorted by checkpoint timestamp in descending order.
"""
checkpoint_info = ray.worker.global_state.actor_checkpoint_info(actor_id)
checkpoint_info = ray.state.state.actor_checkpoint_info(actor_id)
if checkpoint_info is None:
return []
checkpoints = [
Expand Down
13 changes: 3 additions & 10 deletions python/ray/experimental/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
from __future__ import division
from __future__ import print_function

from .features import (
flush_redis_unsafe, flush_task_and_object_metadata_unsafe,
flush_finished_tasks_unsafe, flush_evicted_objects_unsafe,
_flush_finished_tasks_unsafe_shard, _flush_evicted_objects_unsafe_shard)
from .gcs_flush_policy import (set_flushing_policy, GcsFlushPolicy,
SimpleGcsFlushPolicy)
from .named_actors import get_actor, register_actor
Expand All @@ -20,10 +16,7 @@ def TensorFlowVariables(*args, **kwargs):


__all__ = [
"TensorFlowVariables", "flush_redis_unsafe",
"flush_task_and_object_metadata_unsafe", "flush_finished_tasks_unsafe",
"flush_evicted_objects_unsafe", "_flush_finished_tasks_unsafe_shard",
"_flush_evicted_objects_unsafe_shard", "get_actor", "register_actor",
"get", "wait", "set_flushing_policy", "GcsFlushPolicy",
"SimpleGcsFlushPolicy", "set_resource"
"TensorFlowVariables", "get_actor", "register_actor", "get", "wait",
"set_flushing_policy", "GcsFlushPolicy", "SimpleGcsFlushPolicy",
"set_resource"
]
186 changes: 0 additions & 186 deletions python/ray/experimental/features.py

This file was deleted.

Loading

0 comments on commit 6703519

Please sign in to comment.