@@ -18,6 +18,7 @@ def __init__(self, config: ClusterConfiguration):
18
18
19
19
def create_app_wrapper (self ):
20
20
name = self .config .name
21
+ namespace = self .config .namespace
21
22
min_cpu = self .config .min_cpus
22
23
max_cpu = self .config .max_cpus
23
24
min_memory = self .config .min_memory
@@ -29,21 +30,23 @@ def create_app_wrapper(self):
29
30
instascale = self .config .instascale
30
31
instance_types = self .config .machine_types
31
32
env = self .config .envs
32
- return generate_appwrapper (name = name , min_cpu = min_cpu , max_cpu = max_cpu , min_memory = min_memory ,
33
+ return generate_appwrapper (name = name , namespace = namespace , min_cpu = min_cpu , max_cpu = max_cpu , min_memory = min_memory ,
33
34
max_memory = max_memory , gpu = gpu , workers = workers , template = template ,
34
35
image = image , instascale = instascale , instance_types = instance_types , env = env )
35
36
36
- # creates a new cluster with the provided or default spec
37
- def up (self , namespace = 'default' ):
37
+ # creates a new cluster with the provided or default spec
38
+ def up (self ):
39
+ namespace = self .config .namespace
38
40
with oc .project (namespace ):
39
41
oc .invoke ("apply" , ["-f" , self .app_wrapper_yaml ])
40
42
41
- def down (self , namespace = 'default' ):
43
+ def down (self ):
44
+ namespace = self .config .namespace
42
45
with oc .project (namespace ):
43
46
oc .invoke ("delete" , ["AppWrapper" , self .app_wrapper_name ])
44
47
45
48
def status (self , print_to_console = True ):
46
- cluster = _ray_cluster_status (self .config .name )
49
+ cluster = _ray_cluster_status (self .config .name , self . config . namespace )
47
50
if cluster :
48
51
#overriding the number of gpus with requested
49
52
cluster .worker_gpu = self .config .gpu
@@ -55,8 +58,8 @@ def status(self, print_to_console=True):
55
58
pretty_print .print_no_resources_found ()
56
59
return None
57
60
58
- def cluster_uri (self , namespace = 'default' ):
59
- return f'ray://{ self .config .name } -head-svc.{ namespace } .svc:10001'
61
+ def cluster_uri (self ):
62
+ return f'ray://{ self .config .name } -head-svc.{ self . config . namespace } .svc:10001'
60
63
61
64
def cluster_dashboard_uri (self , namespace = 'default' ):
62
65
try :
@@ -68,13 +71,12 @@ def cluster_dashboard_uri(self, namespace='default'):
68
71
return "Dashboard route not available yet. Did you run cluster.up()?"
69
72
70
73
71
-
72
74
# checks whether the ray cluster is ready
73
75
def is_ready (self , print_to_console = True ):
74
76
ready = False
75
77
status = CodeFlareClusterStatus .UNKNOWN
76
78
# check the app wrapper status
77
- appwrapper = _app_wrapper_status (self .config .name )
79
+ appwrapper = _app_wrapper_status (self .config .name , self . config . namespace )
78
80
if appwrapper :
79
81
if appwrapper .status in [AppWrapperStatus .RUNNING , AppWrapperStatus .COMPLETED , AppWrapperStatus .RUNNING_HOLD_COMPLETION ]:
80
82
ready = False
@@ -91,7 +93,7 @@ def is_ready(self, print_to_console=True):
91
93
return ready , status # no need to check the ray status since still in queue
92
94
93
95
# check the ray cluster status
94
- cluster = _ray_cluster_status (self .config .name )
96
+ cluster = _ray_cluster_status (self .config .name , self . config . namespace )
95
97
if cluster :
96
98
if cluster .status == RayClusterStatus .READY :
97
99
ready = True
@@ -106,16 +108,19 @@ def is_ready(self, print_to_console=True):
106
108
pretty_print .print_clusters ([cluster ])
107
109
return status , ready
108
110
111
+ def get_current_namespace ():
112
+ namespace = oc .invoke ("project" ,["-q" ]).actions ()[0 ].out .strip ()
113
+ return namespace
109
114
110
- def list_all_clusters (print_to_console = True ):
111
- clusters = _get_ray_clusters ()
115
+ def list_all_clusters (namespace , print_to_console = True ):
116
+ clusters = _get_ray_clusters (namespace )
112
117
if print_to_console :
113
118
pretty_print .print_clusters (clusters )
114
119
return clusters
115
120
116
121
117
- def list_all_queued (print_to_console = True ):
118
- app_wrappers = _get_app_wrappers (filter = [AppWrapperStatus .RUNNING , AppWrapperStatus .PENDING ])
122
+ def list_all_queued (namespace , print_to_console = True ):
123
+ app_wrappers = _get_app_wrappers ( namespace , filter = [AppWrapperStatus .RUNNING , AppWrapperStatus .PENDING ])
119
124
if print_to_console :
120
125
pretty_print .print_app_wrappers_status (app_wrappers )
121
126
return app_wrappers
@@ -158,7 +163,7 @@ def _get_ray_clusters(namespace='default') -> List[RayCluster]:
158
163
159
164
160
165
161
- def _get_app_wrappers (filter : List [ AppWrapperStatus ], namespace = 'default' ) -> List [AppWrapper ]:
166
+ def _get_app_wrappers (namespace = 'default' , filter = List [ AppWrapperStatus ] ) -> List [AppWrapper ]:
162
167
list_of_app_wrappers = []
163
168
164
169
with oc .project (namespace ), oc .timeout (10 * 60 ):
0 commit comments