Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/codeflare_sdk/cluster/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,9 @@ def from_k8_cluster_object(
mcad=mcad,
write_to_file=write_to_file,
verify_tls=verify_tls,
local_queue=rc["metadata"]
.get("labels", dict())
.get("kueue.x-k8s.io/queue-name", None),
)
return Cluster(cluster_config)

Expand Down
31 changes: 31 additions & 0 deletions tests/unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,7 @@ def get_ray_obj(group, version, namespace, plural, cls=None):
"resourceName": "quicktest",
"workload.codeflare.dev/appwrapper": "quicktest",
"orderedinstance": "m4.xlarge_g4dn.xlarge",
"kueue.x-k8s.io/queue-name": "team-a-queue",
},
"managedFields": [
{
Expand Down Expand Up @@ -2483,6 +2484,36 @@ def test_get_cluster(mocker):
assert cluster_config.num_workers == 1


def test_get_cluster_no_mcad(mocker):
mocker.patch("kubernetes.client.ApisApi.get_api_versions")
mocker.patch("kubernetes.config.load_kube_config", return_value="ignore")
mocker.patch(
"kubernetes.client.CustomObjectsApi.list_namespaced_custom_object",
side_effect=get_ray_obj,
)
mocker.patch(
"kubernetes.client.NetworkingV1Api.list_namespaced_ingress",
return_value=ingress_retrieval(cluster_name="quicktest", client_ing=True),
)
cluster = get_cluster("quicktest")
cluster_config = cluster.config
assert cluster_config.name == "quicktest" and cluster_config.namespace == "ns"
assert (
"m4.xlarge" in cluster_config.machine_types
and "g4dn.xlarge" in cluster_config.machine_types
)
assert cluster_config.min_cpus == 1 and cluster_config.max_cpus == 1
assert cluster_config.min_memory == "2G" and cluster_config.max_memory == "2G"
assert cluster_config.num_gpus == 0
assert cluster_config.instascale
assert (
cluster_config.image
== "ghcr.io/foundation-model-stack/base:ray2.1.0-py38-gpu-pytorch1.12.0cu116-20221213-193103"
)
assert cluster_config.num_workers == 1
assert cluster_config.local_queue == "team-a-queue"


def route_retrieval(group, version, namespace, plural, name):
assert group == "route.openshift.io"
assert version == "v1"
Expand Down