Skip to content

Commit 55c933a

Browse files
committed
Updated get_cluster to account for the new kueue parameter
1 parent 2af7f5b commit 55c933a

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/codeflare_sdk/cluster/cluster.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ def job_logs(self, job_id: str) -> str:
461461
def from_k8_cluster_object(
462462
rc,
463463
appwrapper=True,
464+
kueue=True,
464465
write_to_file=False,
465466
verify_tls=True,
466467
):
@@ -470,6 +471,11 @@ def from_k8_cluster_object(
470471
if "orderedinstance" in rc["metadata"]["labels"]
471472
else []
472473
)
474+
local_queue = (
475+
rc["metadata"].get("labels", dict()).get("kueue.x-k8s.io/queue-name", None)
476+
if kueue
477+
else None
478+
)
473479

474480
cluster_config = ClusterConfiguration(
475481
name=rc["metadata"]["name"],
@@ -499,9 +505,8 @@ def from_k8_cluster_object(
499505
appwrapper=appwrapper,
500506
write_to_file=write_to_file,
501507
verify_tls=verify_tls,
502-
local_queue=rc["metadata"]
503-
.get("labels", dict())
504-
.get("kueue.x-k8s.io/queue-name", None),
508+
kueue=kueue,
509+
local_queue=local_queue,
505510
)
506511
return Cluster(cluster_config)
507512

@@ -634,9 +639,11 @@ def get_cluster(
634639
for rc in rcs["items"]:
635640
if rc["metadata"]["name"] == cluster_name:
636641
appwrapper = _check_aw_exists(cluster_name, namespace)
642+
kueue = _check_kueue_enabled(rc)
637643
return Cluster.from_k8_cluster_object(
638644
rc,
639645
appwrapper=appwrapper,
646+
kueue=kueue,
640647
write_to_file=write_to_file,
641648
verify_tls=verify_tls,
642649
)
@@ -691,6 +698,14 @@ def _check_aw_exists(name: str, namespace: str) -> bool:
691698
return False
692699

693700

701+
def _check_kueue_enabled(rc) -> bool:
702+
# This function will check if a Ray Cluster is being managed by Kueue by checking for the local queue label
703+
for label in rc["metadata"]["labels"]:
704+
if label == "kueue.x-k8s.io/queue-name":
705+
return True
706+
return False
707+
708+
694709
# Cant test this until get_current_namespace is fixed and placed in this function over using `self`
695710
def _get_ingress_domain(self): # pragma: no cover
696711
config_check()

0 commit comments

Comments
 (0)