mirror of
https://github.com/wassname/ray.git
synced 2026-08-11 11:24:51 +08:00
This reverts commit f500292d41.
This commit is contained in:
@@ -33,8 +33,9 @@ def test_actor_groups(ray_start_with_dashboard):
|
||||
foo_actors = [Foo.remote(4), Foo.remote(5)]
|
||||
infeasible_actor = InfeasibleActor.remote() # noqa
|
||||
results = [actor.do_task.remote() for actor in foo_actors] # noqa
|
||||
assert (wait_until_server_available(ray_start_with_dashboard["webui_url"])
|
||||
is True)
|
||||
webui_url = ray_start_with_dashboard["webui_url"]
|
||||
assert wait_until_server_available(webui_url)
|
||||
webui_url = format_web_url(webui_url)
|
||||
|
||||
timeout_seconds = 5
|
||||
@@ -74,66 +75,5 @@ def test_actor_groups(ray_start_with_dashboard):
|
||||
raise Exception(f"Timed out while testing, {ex_stack}")
|
||||
|
||||
|
||||
def test_kill_actor(ray_start_with_dashboard):
|
||||
@ray.remote
|
||||
class Actor:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def f(self):
|
||||
ray.show_in_dashboard("test")
|
||||
return os.getpid()
|
||||
|
||||
a = Actor.remote()
|
||||
worker_pid = ray.get(a.f.remote()) # noqa
|
||||
|
||||
webui_url = ray_start_with_dashboard["webui_url"]
|
||||
assert wait_until_server_available(webui_url)
|
||||
webui_url = format_web_url(webui_url)
|
||||
|
||||
def actor_killed(pid):
|
||||
"""Check For the existence of a unix pid."""
|
||||
try:
|
||||
os.kill(pid, 0)
|
||||
except OSError:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def get_actor():
|
||||
resp = requests.get(f"{webui_url}/logical/actor_groups")
|
||||
resp.raise_for_status()
|
||||
actor_groups_resp = resp.json()
|
||||
assert actor_groups_resp["result"] is True, actor_groups_resp["msg"]
|
||||
actor_groups = actor_groups_resp["data"]["actorGroups"]
|
||||
actor = actor_groups["Actor"]["entries"][0]
|
||||
return actor
|
||||
|
||||
def kill_actor_using_dashboard(actor):
|
||||
resp = requests.get(
|
||||
webui_url + "/logical/kill_actor",
|
||||
params={
|
||||
"actorId": actor["actorId"],
|
||||
"ipAddress": actor["ipAddress"],
|
||||
"port": actor["port"]
|
||||
})
|
||||
resp.raise_for_status()
|
||||
resp_json = resp.json()
|
||||
assert resp_json["result"] is True, "msg" in resp_json
|
||||
|
||||
start = time.time()
|
||||
last_exc = None
|
||||
while time.time() - start <= 10:
|
||||
try:
|
||||
actor = get_actor()
|
||||
kill_actor_using_dashboard(actor)
|
||||
last_exc = None
|
||||
break
|
||||
except (KeyError, AssertionError) as e:
|
||||
last_exc = e
|
||||
time.sleep(.1)
|
||||
assert last_exc is None
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(pytest.main(["-v", __file__]))
|
||||
|
||||
@@ -94,15 +94,23 @@ class ReporterAgent(dashboard_utils.DashboardAgentModule,
|
||||
return reporter_pb2.GetProfilingStatsReply(
|
||||
profiling_stats=profiling_stats, std_out=stdout, std_err=stderr)
|
||||
|
||||
async def ReportOCMetrics(self, request, context):
|
||||
# This function receives a GRPC containing OpenCensus (OC) metrics
|
||||
# from a Ray process, then exposes those metrics to Prometheus.
|
||||
async def ReportMetrics(self, request, context):
|
||||
# NOTE: Exceptions are not propagated properly
|
||||
# when we don't catch them here.
|
||||
try:
|
||||
self._metrics_agent.record_metric_points_from_protobuf(
|
||||
request.metrics)
|
||||
except Exception:
|
||||
metrcs_description_required = (
|
||||
self._metrics_agent.record_metrics_points(
|
||||
request.metrics_points))
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
logger.error(traceback.format_exc())
|
||||
return reporter_pb2.ReportOCMetricsReply()
|
||||
|
||||
# If metrics description is missing, we should notify cpp processes
|
||||
# that we need them. Cpp processes will then report them to here.
|
||||
# We need it when (1) a new metric is reported (application metric)
|
||||
# (2) a reporter goes down and restarted (currently not implemented).
|
||||
return reporter_pb2.ReportMetricsReply(
|
||||
metrcs_description_required=metrcs_description_required)
|
||||
|
||||
@staticmethod
|
||||
def _get_cpu_percent():
|
||||
@@ -117,7 +125,8 @@ class ReporterAgent(dashboard_utils.DashboardAgentModule,
|
||||
try:
|
||||
gpus = gpustat.new_query().gpus
|
||||
except Exception as e:
|
||||
logger.debug(f"gpustat failed to retrieve GPU information: {e}")
|
||||
logger.debug(
|
||||
"gpustat failed to retrieve GPU information: {}".format(e))
|
||||
for gpu in gpus:
|
||||
# Note the keys in this dict have periods which throws
|
||||
# off javascript so we change .s to _s
|
||||
@@ -224,8 +233,12 @@ class ReporterAgent(dashboard_utils.DashboardAgentModule,
|
||||
"cmdline": self._get_raylet_cmdline(),
|
||||
}
|
||||
|
||||
async def _perform_iteration(self, aioredis_client):
|
||||
async def _perform_iteration(self):
|
||||
"""Get any changes to the log files and push updates to Redis."""
|
||||
aioredis_client = await aioredis.create_redis_pool(
|
||||
address=self._dashboard_agent.redis_address,
|
||||
password=self._dashboard_agent.redis_password)
|
||||
|
||||
while True:
|
||||
try:
|
||||
stats = self._get_all_stats()
|
||||
@@ -236,8 +249,5 @@ class ReporterAgent(dashboard_utils.DashboardAgentModule,
|
||||
reporter_consts.REPORTER_UPDATE_INTERVAL_MS / 1000)
|
||||
|
||||
async def run(self, server):
|
||||
aioredis_client = await aioredis.create_redis_pool(
|
||||
address=self._dashboard_agent.redis_address,
|
||||
password=self._dashboard_agent.redis_password)
|
||||
reporter_pb2_grpc.add_ReporterServiceServicer_to_server(self, server)
|
||||
await self._perform_iteration(aioredis_client)
|
||||
await self._perform_iteration()
|
||||
|
||||
@@ -130,7 +130,7 @@ class TuneController(dashboard_utils.DashboardHeadModule):
|
||||
|
||||
# search through all the sub_directories in log directory
|
||||
analysis = Analysis(str(self._logdir))
|
||||
df = analysis.dataframe(metric=None, mode=None)
|
||||
df = analysis.dataframe(metric="episode_reward_mean", mode="max")
|
||||
|
||||
if len(df) == 0 or "trial_id" not in df.columns:
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user