@@ -194,40 +194,33 @@ def apply(self, force=False):
194
194
# check if RayCluster CustomResourceDefinition exists if not throw RuntimeError
195
195
self ._throw_for_no_raycluster ()
196
196
namespace = self .config .namespace
197
-
197
+ name = self . config . name
198
198
try :
199
199
self .config_check ()
200
200
api_instance = client .CustomObjectsApi (get_api_client ())
201
201
crds = self .get_dynamic_client ().resources
202
- api_instance = crds .get (
203
- api_version = "workload.codeflare.dev/v1beta2" , kind = "AppWrapper"
204
- )
205
202
if self .config .appwrapper :
203
+ api_version = "workload.codeflare.dev/v1beta2"
204
+ api_instance = crds .get (api_version , kind = "AppWrapper" )
205
+ # defaulting body to resource_yaml
206
+ body = self .resource_yaml
206
207
if self .config .write_to_file :
208
+ # if write_to_file is True, load the file from AppWrapper yaml and update body
207
209
with open (self .resource_yaml ) as f :
208
210
aw = yaml .load (f , Loader = yaml .FullLoader )
209
- api_instance .server_side_apply (
210
- group = "workload.codeflare.dev" ,
211
- version = "v1beta2" ,
212
- namespace = namespace ,
213
- plural = "appwrappers" ,
214
- body = aw ,
215
- )
216
- else :
217
- api_instance .server_side_apply (
218
- group = "workload.codeflare.dev" ,
219
- version = "v1beta2" ,
220
- namespace = namespace ,
221
- plural = "appwrappers" ,
222
- body = self .resource_yaml ,
223
- )
224
- print (f"AppWrapper: '{ self .config .name } ' has successfully been created" )
211
+ body = aw
212
+ api_instance .server_side_apply (
213
+ group = "workload.codeflare.dev" ,
214
+ version = "v1beta2" ,
215
+ namespace = namespace ,
216
+ plural = "appwrappers" ,
217
+ body = body ,
218
+ )
219
+ print (f"AppWrapper: '{ name } ' has successfully been created" )
225
220
else :
226
221
api_instance = crds .get (api_version = "ray.io/v1" , kind = "RayCluster" )
227
222
self ._component_resources_apply (namespace , api_instance )
228
- print (
229
- f"Ray Cluster: '{ self .config .name } ' has successfully been applied"
230
- )
223
+ print (f"Ray Cluster: '{ name } ' has successfully been applied" )
231
224
except Exception as e : # pragma: no cover
232
225
return _kube_api_error_handling (e )
233
226
0 commit comments