8
8
import aiohttp .web
9
9
from aiohttp .web import Response
10
10
11
- import ray .dashboard .optional_utils as dashboard_optional_utils
12
- import ray .dashboard .utils as dashboard_utils
11
+ import ray
13
12
from ray import ActorID
14
13
from ray ._private .ray_constants import env_integer
15
14
from ray ._private .usage .usage_lib import TagKey , record_extra_usage_tag
28
27
options_from_req ,
29
28
)
30
29
from ray .dashboard .utils import RateLimitedModule
30
+ from ray .dashboard .subprocesses .routes import SubprocessRouteTable as routes
31
+ from ray .dashboard .subprocesses .module import SubprocessModule
32
+ from ray .dashboard .subprocesses .utils import ResponseType
31
33
from ray .util .state .common import DEFAULT_LOG_LIMIT , DEFAULT_RPC_TIMEOUT , GetLogOptions
32
34
from ray .util .state .exception import DataSourceUnavailable
33
35
from ray .util .state .state_manager import StateDataSourceClient
34
36
35
37
logger = logging .getLogger (__name__ )
36
- routes = dashboard_optional_utils .DashboardHeadRouteTable
37
38
38
39
# NOTE: Executor in this head is intentionally constrained to just 1 thread by
39
40
# default to limit its concurrency, therefore reducing potential for
43
44
)
44
45
45
46
46
- class StateHead (dashboard_utils . DashboardHeadModule , RateLimitedModule ):
47
+ class StateHead (SubprocessModule , RateLimitedModule ):
47
48
"""Module to obtain state information from the Ray cluster.
48
49
49
50
It is responsible for state observability APIs such as
50
51
ray.list_actors(), ray.get_actor(), ray.summary_actors().
51
52
"""
52
53
53
- def __init__ (
54
- self ,
55
- config : dashboard_utils .DashboardHeadModuleConfig ,
56
- ):
54
+ def __init__ (self , * args , ** kwargs ):
57
55
"""Initialize for handling RESTful requests from State API Client"""
58
- dashboard_utils . DashboardHeadModule . __init__ (self , config )
56
+ SubprocessModule . __init__ (self , * args , ** kwargs )
59
57
# We don't allow users to configure too high a rate limit
60
58
RateLimitedModule .__init__ (
61
59
self ,
@@ -73,6 +71,10 @@ def __init__(
73
71
thread_name_prefix = "state_head_executor" ,
74
72
)
75
73
74
+ # To make sure that the internal KV is initialized by getting the lazy property
75
+ assert self .gcs_client is not None
76
+ assert ray .experimental .internal_kv ._internal_kv_initialized ()
77
+
76
78
async def limit_handler_ (self ):
77
79
return do_reply (
78
80
success = False ,
@@ -191,7 +193,7 @@ async def list_logs(self, req: aiohttp.web.Request) -> aiohttp.web.Response:
191
193
192
194
return do_reply (success = True , error_message = "" , result = result )
193
195
194
- @routes .get ("/api/v0/logs/{media_type}" )
196
+ @routes .get ("/api/v0/logs/{media_type}" , resp_type = ResponseType . STREAM )
195
197
@RateLimitedModule .enforce_max_concurrent_calls
196
198
async def get_logs (self , req : aiohttp .web .Request ):
197
199
"""
@@ -333,7 +335,8 @@ async def delayed_response(self, req: aiohttp.web.Request):
333
335
partial_failure_warning = None ,
334
336
)
335
337
336
- async def run (self , server ):
338
+ async def run (self ):
339
+ await SubprocessModule .run (self )
337
340
gcs_channel = self .aiogrpc_gcs_channel
338
341
self ._state_api_data_source_client = StateDataSourceClient (
339
342
gcs_channel , self .gcs_aio_client
@@ -343,7 +346,3 @@ async def run(self, server):
343
346
self ._executor ,
344
347
)
345
348
self ._log_api = LogsManager (self ._state_api_data_source_client )
346
-
347
- @staticmethod
348
- def is_minimal_module ():
349
- return False
0 commit comments