@@ -339,6 +339,26 @@ <h1 class="title">Module <code>codeflare_sdk.utils.generate_yaml</code></h1>
339
339
)
340
340
341
341
342
+ def local_queue_exists(namespace: str, local_queue_name: str):
343
+ # get all local queues in the namespace
344
+ try:
345
+ config_check()
346
+ api_instance = client.CustomObjectsApi(api_config_handler())
347
+ local_queues = api_instance.list_namespaced_custom_object(
348
+ group="kueue.x-k8s.io",
349
+ version="v1beta1",
350
+ namespace=namespace,
351
+ plural="localqueues",
352
+ )
353
+ except Exception as e: # pragma: no cover
354
+ return _kube_api_error_handling(e)
355
+ # check if local queue with the name provided in cluster config exists
356
+ for lq in local_queues["items"]:
357
+ if lq["metadata"]["name"] == local_queue_name:
358
+ return True
359
+ return False
360
+
361
+
342
362
def write_components(
343
363
user_yaml: dict,
344
364
output_file_name: str,
@@ -355,6 +375,10 @@ <h1 class="title">Module <code>codeflare_sdk.utils.generate_yaml</code></h1>
355
375
open(output_file_name, "w").close()
356
376
lq_name = local_queue or get_default_kueue_name(namespace)
357
377
cluster_labels = labels
378
+ if not local_queue_exists(namespace, lq_name):
379
+ raise ValueError(
380
+ "local_queue provided does not exist or is not in this namespace. Please provide the correct local_queue name in Cluster Configuration"
381
+ )
358
382
with open(output_file_name, "a") as outfile:
359
383
for component in components:
360
384
if "generictemplate" in component:
@@ -386,6 +410,10 @@ <h1 class="title">Module <code>codeflare_sdk.utils.generate_yaml</code></h1>
386
410
components = user_yaml.get("spec", "resources")["resources"].get("GenericItems")
387
411
lq_name = local_queue or get_default_kueue_name(namespace)
388
412
cluster_labels = labels
413
+ if not local_queue_exists(namespace, lq_name):
414
+ raise ValueError(
415
+ "local_queue provided does not exist or is not in this namespace. Please provide the correct local_queue name in Cluster Configuration"
416
+ )
389
417
for component in components:
390
418
if "generictemplate" in component:
391
419
if (
@@ -748,6 +776,10 @@ <h2 class="section-title" id="header-functions">Functions</h2>
748
776
components = user_yaml.get("spec", "resources")["resources"].get("GenericItems")
749
777
lq_name = local_queue or get_default_kueue_name(namespace)
750
778
cluster_labels = labels
779
+ if not local_queue_exists(namespace, lq_name):
780
+ raise ValueError(
781
+ "local_queue provided does not exist or is not in this namespace. Please provide the correct local_queue name in Cluster Configuration"
782
+ )
751
783
for component in components:
752
784
if "generictemplate" in component:
753
785
if (
@@ -770,6 +802,35 @@ <h2 class="section-title" id="header-functions">Functions</h2>
770
802
return user_yaml</ code > </ pre >
771
803
</ details >
772
804
</ dd >
805
+ < dt id ="codeflare_sdk.utils.generate_yaml.local_queue_exists "> < code class ="name flex ">
806
+ < span > def < span class ="ident "> local_queue_exists</ span > </ span > (< span > namespace: str, local_queue_name: str)</ span >
807
+ </ code > </ dt >
808
+ < dd >
809
+ < div class ="desc "> </ div >
810
+ < details class ="source ">
811
+ < summary >
812
+ < span > Expand source code</ span >
813
+ </ summary >
814
+ < pre > < code class ="python "> def local_queue_exists(namespace: str, local_queue_name: str):
815
+ # get all local queues in the namespace
816
+ try:
817
+ config_check()
818
+ api_instance = client.CustomObjectsApi(api_config_handler())
819
+ local_queues = api_instance.list_namespaced_custom_object(
820
+ group="kueue.x-k8s.io",
821
+ version="v1beta1",
822
+ namespace=namespace,
823
+ plural="localqueues",
824
+ )
825
+ except Exception as e: # pragma: no cover
826
+ return _kube_api_error_handling(e)
827
+ # check if local queue with the name provided in cluster config exists
828
+ for lq in local_queues["items"]:
829
+ if lq["metadata"]["name"] == local_queue_name:
830
+ return True
831
+ return False</ code > </ pre >
832
+ </ details >
833
+ </ dd >
773
834
< dt id ="codeflare_sdk.utils.generate_yaml.read_template "> < code class ="name flex ">
774
835
< span > def < span class ="ident "> read_template</ span > </ span > (< span > template)</ span >
775
836
</ code > </ dt >
@@ -1091,6 +1152,10 @@ <h2 class="section-title" id="header-functions">Functions</h2>
1091
1152
open(output_file_name, "w").close()
1092
1153
lq_name = local_queue or get_default_kueue_name(namespace)
1093
1154
cluster_labels = labels
1155
+ if not local_queue_exists(namespace, lq_name):
1156
+ raise ValueError(
1157
+ "local_queue provided does not exist or is not in this namespace. Please provide the correct local_queue name in Cluster Configuration"
1158
+ )
1094
1159
with open(output_file_name, "a") as outfile:
1095
1160
for component in components:
1096
1161
if "generictemplate" in component:
@@ -1158,6 +1223,7 @@ <h1>Index</h1>
1158
1223
< li > < code > < a title ="codeflare_sdk.utils.generate_yaml.is_openshift_cluster " href ="#codeflare_sdk.utils.generate_yaml.is_openshift_cluster "> is_openshift_cluster</ a > </ code > </ li >
1159
1224
< li > < code > < a title ="codeflare_sdk.utils.generate_yaml.load_appwrapper " href ="#codeflare_sdk.utils.generate_yaml.load_appwrapper "> load_appwrapper</ a > </ code > </ li >
1160
1225
< li > < code > < a title ="codeflare_sdk.utils.generate_yaml.load_components " href ="#codeflare_sdk.utils.generate_yaml.load_components "> load_components</ a > </ code > </ li >
1226
+ < li > < code > < a title ="codeflare_sdk.utils.generate_yaml.local_queue_exists " href ="#codeflare_sdk.utils.generate_yaml.local_queue_exists "> local_queue_exists</ a > </ code > </ li >
1161
1227
< li > < code > < a title ="codeflare_sdk.utils.generate_yaml.read_template " href ="#codeflare_sdk.utils.generate_yaml.read_template "> read_template</ a > </ code > </ li >
1162
1228
< li > < code > < a title ="codeflare_sdk.utils.generate_yaml.update_affinity " href ="#codeflare_sdk.utils.generate_yaml.update_affinity "> update_affinity</ a > </ code > </ li >
1163
1229
< li > < code > < a title ="codeflare_sdk.utils.generate_yaml.update_custompodresources " href ="#codeflare_sdk.utils.generate_yaml.update_custompodresources "> update_custompodresources</ a > </ code > </ li >
0 commit comments