mirror of
https://github.com/wassname/ray.git
synced 2026-06-30 06:46:40 +08:00
Add job table to state API (#5076)
This commit is contained in:
committed by
Robert Nishihara
parent
53d5a8a45f
commit
c5253cc300
@@ -2423,15 +2423,22 @@ def wait_for_num_objects(num_objects, timeout=10):
|
||||
os.environ.get("RAY_USE_NEW_GCS") == "on",
|
||||
reason="New GCS API doesn't have a Python API yet.")
|
||||
def test_global_state_api(shutdown_only):
|
||||
with pytest.raises(Exception):
|
||||
|
||||
error_message = ("The ray global state API cannot be used "
|
||||
"before ray.init has been called.")
|
||||
|
||||
with pytest.raises(Exception, match=error_message):
|
||||
ray.objects()
|
||||
|
||||
with pytest.raises(Exception):
|
||||
with pytest.raises(Exception, match=error_message):
|
||||
ray.tasks()
|
||||
|
||||
with pytest.raises(Exception):
|
||||
with pytest.raises(Exception, match=error_message):
|
||||
ray.nodes()
|
||||
|
||||
with pytest.raises(Exception, match=error_message):
|
||||
ray.jobs()
|
||||
|
||||
ray.init(num_cpus=5, num_gpus=3, resources={"CustomResource": 1})
|
||||
|
||||
resources = {"CPU": 5, "GPU": 3, "CustomResource": 1}
|
||||
@@ -2509,6 +2516,12 @@ def test_global_state_api(shutdown_only):
|
||||
object_table_entry = ray.objects(result_id)
|
||||
assert object_table[result_id] == object_table_entry
|
||||
|
||||
job_table = ray.jobs()
|
||||
|
||||
assert len(job_table) == 1
|
||||
assert job_table[0]["JobID"] == job_id
|
||||
assert job_table[0]["NodeManagerAddress"] == node_ip_address
|
||||
|
||||
|
||||
# TODO(rkn): Pytest actually has tools for capturing stdout and stderr, so we
|
||||
# should use those, but they seem to conflict with Ray's use of faulthandler.
|
||||
|
||||
Reference in New Issue
Block a user