mirror of
https://github.com/wassname/ray.git
synced 2026-07-17 11:32:33 +08:00
[Dashboard] Add Ray Config API to Reporter Head (#11010)
* Add Ray Config API to the backend for fetching config * Address PR comments. * Make reporter cache whole payload * lint Co-authored-by: Max Fitton <max@semprehealth.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import json
|
||||
import logging
|
||||
|
||||
import yaml
|
||||
import os
|
||||
import aiohttp.web
|
||||
from aioredis.pubsub import Receiver
|
||||
from grpc.experimental import aio as aiogrpc
|
||||
@@ -52,6 +53,49 @@ class ReportHead(dashboard_utils.DashboardHeadModule):
|
||||
message="Profiling success.",
|
||||
profiling_info=profiling_info)
|
||||
|
||||
@routes.get("/api/ray_config")
|
||||
async def get_ray_config(self, req) -> aiohttp.web.Response:
|
||||
if self._ray_config is None:
|
||||
try:
|
||||
config_path = os.path.expanduser("~/ray_bootstrap_config.yaml")
|
||||
with open(config_path) as f:
|
||||
cfg = yaml.safe_load(f)
|
||||
except yaml.YAMLError:
|
||||
return await dashboard_utils.rest_response(
|
||||
success=False,
|
||||
message=f"No config found at {config_path}.",
|
||||
)
|
||||
except FileNotFoundError:
|
||||
return await dashboard_utils.rest_response(
|
||||
success=False,
|
||||
message=f"Invalid config, could not load YAML.")
|
||||
|
||||
payload = {
|
||||
"min_workers": cfg["min_workers"],
|
||||
"max_workers": cfg["max_workers"],
|
||||
"initial_workers": cfg["initial_workers"],
|
||||
"autoscaling_mode": cfg["autoscaling_mode"],
|
||||
"idle_timeout_minutes": cfg["idle_timeout_minutes"],
|
||||
}
|
||||
|
||||
try:
|
||||
payload["head_type"] = cfg["head_node"]["InstanceType"]
|
||||
except KeyError:
|
||||
payload["head_type"] = "unknown"
|
||||
|
||||
try:
|
||||
payload["worker_type"] = cfg["worker_nodes"]["InstanceType"]
|
||||
except KeyError:
|
||||
payload["worker_type"] = "unknown"
|
||||
|
||||
self._ray_config = payload
|
||||
|
||||
return await dashboard_utils.rest_response(
|
||||
success=True,
|
||||
message="Fetched ray config.",
|
||||
**self._ray_config,
|
||||
)
|
||||
|
||||
async def run(self, server):
|
||||
aioredis_client = self._dashboard_head.aioredis_client
|
||||
receiver = Receiver()
|
||||
|
||||
Reference in New Issue
Block a user