mirror of
https://github.com/wassname/ray.git
synced 2026-07-28 11:25:04 +08:00
[Dashboard] Display actor task execution info (#6705)
Co-authored-by: Philipp Moritz <pcmoritz@gmail.com>
This commit is contained in:
committed by
Philipp Moritz
co-authored by
Philipp Moritz
parent
ae9a3a2237
commit
0834bda8c1
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
import json
|
||||
import grpc
|
||||
import psutil
|
||||
import requests
|
||||
@@ -7,6 +8,8 @@ import time
|
||||
import ray
|
||||
from ray.core.generated import node_manager_pb2
|
||||
from ray.core.generated import node_manager_pb2_grpc
|
||||
from ray.core.generated import reporter_pb2
|
||||
from ray.core.generated import reporter_pb2_grpc
|
||||
from ray.test_utils import RayTestTimeoutException
|
||||
|
||||
|
||||
@@ -138,7 +141,11 @@ def test_raylet_info_endpoint(shutdown_only):
|
||||
def remote_store(self):
|
||||
self.remote_storage = ray.put("test")
|
||||
|
||||
def getpid(self):
|
||||
return os.getpid()
|
||||
|
||||
c = ActorC.remote()
|
||||
actor_pid = ray.get(c.getpid.remote())
|
||||
c.local_store.remote()
|
||||
c.remote_store.remote()
|
||||
|
||||
@@ -168,7 +175,7 @@ def test_raylet_info_endpoint(shutdown_only):
|
||||
"Timed out while waiting for dashboard to start.")
|
||||
|
||||
assert parent_actor_info["usedResources"]["CPU"] == 2
|
||||
assert parent_actor_info["numExecutedTasks"] == 3
|
||||
assert parent_actor_info["numExecutedTasks"] == 4
|
||||
for _, child_actor_info in children.items():
|
||||
if child_actor_info["state"] == -1:
|
||||
assert child_actor_info["requiredResources"]["CustomResource"] == 1
|
||||
@@ -177,6 +184,61 @@ def test_raylet_info_endpoint(shutdown_only):
|
||||
assert len(child_actor_info["children"]) == 0
|
||||
assert child_actor_info["usedResources"]["CPU"] == 1
|
||||
|
||||
profiling_id = requests.get(
|
||||
webui_url + "/api/launch_profiling",
|
||||
params={
|
||||
"node_id": ray.nodes()[0]["NodeID"],
|
||||
"pid": actor_pid,
|
||||
"duration": 5
|
||||
}).json()
|
||||
start_time = time.time()
|
||||
while True:
|
||||
time.sleep(1)
|
||||
try:
|
||||
profiling_info = requests.get(
|
||||
webui_url + "/api/check_profiling_status",
|
||||
params={
|
||||
"profiling_id": profiling_id,
|
||||
}).json()
|
||||
assert profiling_info["status"] in ("finished", "pending", "error")
|
||||
break
|
||||
except AssertionError:
|
||||
if time.time() - start_time + 10:
|
||||
raise Exception("Timed out while collecting profiling stats.")
|
||||
|
||||
|
||||
def test_profiling_info_endpoint(shutdown_only):
|
||||
ray.init(num_cpus=1)
|
||||
|
||||
redis_client = ray.worker.global_worker.redis_client
|
||||
|
||||
node_ip = ray.nodes()[0]["NodeManagerAddress"]
|
||||
|
||||
while True:
|
||||
reporter_port = redis_client.get("REPORTER_PORT:{}".format(node_ip))
|
||||
if reporter_port:
|
||||
break
|
||||
|
||||
reporter_channel = grpc.insecure_channel("{}:{}".format(
|
||||
node_ip, int(reporter_port)))
|
||||
reporter_stub = reporter_pb2_grpc.ReporterServiceStub(reporter_channel)
|
||||
|
||||
@ray.remote(num_cpus=1)
|
||||
class ActorA:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def getpid(self):
|
||||
return os.getpid()
|
||||
|
||||
a = ActorA.remote()
|
||||
actor_pid = ray.get(a.getpid.remote())
|
||||
|
||||
reply = reporter_stub.GetProfilingStats(
|
||||
reporter_pb2.GetProfilingStatsRequest(pid=actor_pid, duration=10))
|
||||
profiling_stats = json.loads(reply.profiling_stats)
|
||||
assert profiling_stats is not None
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import pytest
|
||||
|
||||
Reference in New Issue
Block a user