@@ -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,19 +58,19 @@ 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
- def cluster_dashboard_uri (self , namespace = 'default' ):
62
- return f'http://{ self .config .name } -head-svc.{ namespace } .svc:8265'
64
+ def cluster_dashboard_uri (self ):
65
+ return f'http://{ self .config .name } -head-svc.{ self . config . namespace } .svc:8265'
63
66
64
67
65
68
# checks whether the ray cluster is ready
66
69
def is_ready (self , print_to_console = True ):
67
70
ready = False
68
71
status = CodeFlareClusterStatus .UNKNOWN
69
72
# check the app wrapper status
70
- appwrapper = _app_wrapper_status (self .config .name )
73
+ appwrapper = _app_wrapper_status (self .config .name , self . config . namespace )
71
74
if appwrapper :
72
75
if appwrapper .status in [AppWrapperStatus .RUNNING , AppWrapperStatus .COMPLETED , AppWrapperStatus .RUNNING_HOLD_COMPLETION ]:
73
76
ready = False
@@ -84,7 +87,7 @@ def is_ready(self, print_to_console=True):
84
87
return ready , status # no need to check the ray status since still in queue
85
88
86
89
# check the ray cluster status
87
- cluster = _ray_cluster_status (self .config .name )
90
+ cluster = _ray_cluster_status (self .config .name , self . config . namespace )
88
91
if cluster :
89
92
if cluster .status == RayClusterStatus .READY :
90
93
ready = True
@@ -99,16 +102,19 @@ def is_ready(self, print_to_console=True):
99
102
pretty_print .print_clusters ([cluster ])
100
103
return status , ready
101
104
105
+ def get_current_namespace ():
106
+ namespace = oc .invoke ("project" ,["-q" ]).actions ()[0 ].out .strip ()
107
+ return namespace
102
108
103
- def list_all_clusters (print_to_console = True ):
104
- clusters = _get_ray_clusters ()
109
+ def list_all_clusters (namespace , print_to_console = True ):
110
+ clusters = _get_ray_clusters (namespace )
105
111
if print_to_console :
106
112
pretty_print .print_clusters (clusters )
107
113
return clusters
108
114
109
115
110
- def list_all_queued (print_to_console = True ):
111
- app_wrappers = _get_app_wrappers (filter = [AppWrapperStatus .RUNNING , AppWrapperStatus .PENDING ])
116
+ def list_all_queued (namespace , print_to_console = True ):
117
+ app_wrappers = _get_app_wrappers ( namespace , filter = [AppWrapperStatus .RUNNING , AppWrapperStatus .PENDING ])
112
118
if print_to_console :
113
119
pretty_print .print_app_wrappers_status (app_wrappers )
114
120
return app_wrappers
@@ -151,7 +157,7 @@ def _get_ray_clusters(namespace='default') -> List[RayCluster]:
151
157
152
158
153
159
154
- def _get_app_wrappers (filter : List [ AppWrapperStatus ], namespace = 'default' ) -> List [AppWrapper ]:
160
+ def _get_app_wrappers (namespace = 'default' , filter = List [ AppWrapperStatus ] ) -> List [AppWrapper ]:
155
161
list_of_app_wrappers = []
156
162
157
163
with oc .project (namespace ), oc .timeout (10 * 60 ):
0 commit comments