mirror of
https://github.com/wassname/ray.git
synced 2026-07-17 11:32:33 +08:00
[Dashboard] Logical view backend for dashboard (#6590)
This commit is contained in:
committed by
Philipp Moritz
parent
8b16847c02
commit
65acb54553
@@ -5,6 +5,7 @@ from __future__ import print_function
|
||||
import os
|
||||
import grpc
|
||||
import psutil
|
||||
import requests
|
||||
import time
|
||||
|
||||
import ray
|
||||
@@ -60,11 +61,12 @@ def test_worker_stats(shutdown_only):
|
||||
reply = try_get_node_stats()
|
||||
target_worker_present = False
|
||||
for worker in reply.workers_stats:
|
||||
if worker.webui_display == "test":
|
||||
stats = worker.core_worker_stats
|
||||
if stats.webui_display == "test":
|
||||
target_worker_present = True
|
||||
assert worker.pid == worker_pid
|
||||
else:
|
||||
assert worker.webui_display == ""
|
||||
assert stats.webui_display == ""
|
||||
assert target_worker_present
|
||||
|
||||
# Test show_in_webui for remote actors.
|
||||
@@ -73,11 +75,12 @@ def test_worker_stats(shutdown_only):
|
||||
reply = try_get_node_stats()
|
||||
target_worker_present = False
|
||||
for worker in reply.workers_stats:
|
||||
if worker.webui_display == "test":
|
||||
stats = worker.core_worker_stats
|
||||
if stats.webui_display == "test":
|
||||
target_worker_present = True
|
||||
assert worker.pid == worker_pid
|
||||
else:
|
||||
assert worker.webui_display == ""
|
||||
assert stats.webui_display == ""
|
||||
assert target_worker_present
|
||||
|
||||
timeout_seconds = 20
|
||||
@@ -94,7 +97,6 @@ def test_worker_stats(shutdown_only):
|
||||
continue
|
||||
|
||||
# Check that the rest of the processes are workers, 1 for each CPU.
|
||||
print(reply)
|
||||
assert len(reply.workers_stats) == num_cpus + 1
|
||||
views = [view.view_name for view in reply.view_data]
|
||||
assert "redis_latency" in views
|
||||
@@ -112,6 +114,64 @@ def test_worker_stats(shutdown_only):
|
||||
break
|
||||
|
||||
|
||||
def test_raylet_info_endpoint(shutdown_only):
|
||||
addresses = ray.init(include_webui=True, num_cpus=6)
|
||||
|
||||
@ray.remote(num_cpus=1)
|
||||
class A(object):
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def f(self):
|
||||
return os.getpid()
|
||||
|
||||
@ray.remote(num_cpus=2)
|
||||
class B(object):
|
||||
def __init__(self):
|
||||
self.children = [A.remote(), A.remote()]
|
||||
|
||||
def f(self):
|
||||
return os.getpid(), ray.get(
|
||||
[child.f.remote() for child in self.children])
|
||||
|
||||
# TODO: Currently there is a race condition of Dashboard subscription
|
||||
# and actor initialization. This will be fixed after #6629 is merged.
|
||||
time.sleep(10)
|
||||
|
||||
b = B.remote()
|
||||
pids = ray.get(b.f.remote())
|
||||
assert len(pids) == 2 and len(pids[1]) == 2
|
||||
|
||||
start_time = time.time()
|
||||
while True:
|
||||
time.sleep(1)
|
||||
try:
|
||||
webui_url = addresses["webui_url"]
|
||||
webui_url = webui_url.replace("localhost", "http://127.0.0.1")
|
||||
raylet_info = requests.get(webui_url + "/api/raylet_info").json()
|
||||
actor_info = raylet_info["result"]["actorInfo"]
|
||||
try:
|
||||
assert len(actor_info) == 1
|
||||
print("actor_info", actor_info)
|
||||
_, parent_actor_info = actor_info.popitem()
|
||||
children = parent_actor_info["children"]
|
||||
assert len(children) == 2
|
||||
break
|
||||
except AssertionError:
|
||||
if time.time() > start_time + 30:
|
||||
raise Exception(
|
||||
"Timed out while waiting for actorInfo to show up.")
|
||||
except requests.exceptions.ConnectionError:
|
||||
if time.time() > start_time + 30:
|
||||
raise Exception(
|
||||
"Timed out while waiting for dashboard to start.")
|
||||
|
||||
assert parent_actor_info["usedResources"]["CPU"] == 2
|
||||
for _, child_actor_info in children.items():
|
||||
assert len(child_actor_info["children"]) == 0
|
||||
assert child_actor_info["usedResources"]["CPU"] == 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import pytest
|
||||
import sys
|
||||
|
||||
Reference in New Issue
Block a user