30
30
from os import urandom
31
31
from base64 import b64encode
32
32
from urllib3 .util import parse_url
33
+ from kubernetes .client .rest import ApiException
33
34
34
35
35
36
def read_template (template ):
@@ -307,6 +308,32 @@ def get_default_kueue_name(namespace: str):
307
308
"Default Local Queue with kueue.x-k8s.io/default-queue: true annotation not found please create a default Local Queue or provide the local_queue name in Cluster Configuration"
308
309
)
309
310
311
+ # test function
312
+
313
+ # def _throw_for_no_raycluster( user_yaml: dict,
314
+ # output_file_name: str,
315
+ # namespace: str,
316
+ # local_queue: Optional[str],
317
+ # labels: dict,):
318
+ # api_instance = client.CustomObjectsApi(api_config_handler())
319
+ # print('hello')
320
+ # # try:
321
+ # # api_instance.list_namespaced_custom_object(
322
+ # # group="kueue.x-k8s.io",
323
+ # # version="v1",
324
+ # # namespace=namespace,
325
+ # # plural="localqueues",
326
+ # # )
327
+ # # except ApiException as e:
328
+ # # if e.status == 404:
329
+ # # raise RuntimeError(
330
+ # # "RayCluster CustomResourceDefinition unavailable contact your administrator."
331
+ # # )
332
+ # # else:
333
+ # # raise RuntimeError(
334
+ # # "Failed to get RayCluster CustomResourceDefinition: " + str(e)
335
+ # # )
336
+
310
337
311
338
def local_queue_exists (namespace : str , local_queue_name : str ):
312
339
# get all local queues in the namespace
@@ -341,6 +368,12 @@ def write_components(
341
368
os .makedirs (directory_path )
342
369
343
370
components = user_yaml .get ("spec" , "resources" )["resources" ].get ("GenericItems" )
371
+ # check if RayCluster CustomResourceDefinition exists if not throw RuntimeError
372
+ # _throw_for_no_raycluster()
373
+ # if local_queue is None:
374
+ # print(
375
+ # "Kueue is not installed or won't be used. The absence of CRDs may lack the necessary functionality."
376
+ # )
344
377
open (output_file_name , "w" ).close ()
345
378
lq_name = local_queue or get_default_kueue_name (namespace )
346
379
cluster_labels = labels
@@ -367,22 +400,31 @@ def write_components(
367
400
)
368
401
print (f"Written to: { output_file_name } " )
369
402
370
-
371
403
def load_components (
372
404
user_yaml : dict ,
373
405
name : str ,
374
406
namespace : str ,
375
407
local_queue : Optional [str ],
376
- labels : dict ,
408
+ labels : dict
377
409
):
378
410
component_list = []
379
411
components = user_yaml .get ("spec" , "resources" )["resources" ].get ("GenericItems" )
380
412
lq_name = local_queue or get_default_kueue_name (namespace )
381
413
cluster_labels = labels
414
+ < << << << HEAD
382
415
if not local_queue_exists (namespace , lq_name ):
383
416
raise ValueError (
384
417
"local_queue provided does not exist or is not in this namespace. Please provide the correct local_queue name in Cluster Configuration"
385
418
)
419
+ == == == =
420
+
421
+ # _throw_for_no_raycluster()
422
+
423
+ # if local_queue is None:
424
+ # print(
425
+ # "Kueue is not installed or won't be used. The absence of CRDs may lack the necessary functionality."
426
+ # )
427
+ >> >> >> > 1 d38c8d (prep )
386
428
for component in components :
387
429
if "generictemplate" in component :
388
430
if (
0 commit comments