Skip to content

Commit

Permalink
Removed get cluster fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Bobbins228 authored and astefanutti committed Dec 20, 2023
1 parent 27908c2 commit dce93f7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
9 changes: 3 additions & 6 deletions src/codeflare_sdk/cluster/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ def torchx_config(
to_return["requirements"] = requirements
return to_return

def from_k8_cluster_object(rc, mcad=True, ingress_domain=None):
def from_k8_cluster_object(rc, mcad=True):
machine_types = (
rc["metadata"]["labels"]["orderedinstance"].split("_")
if "orderedinstance" in rc["metadata"]["labels"]
Expand Down Expand Up @@ -532,7 +532,6 @@ def from_k8_cluster_object(rc, mcad=True, ingress_domain=None):
]["image"],
local_interactive=local_interactive,
mcad=mcad,
ingress_domain=ingress_domain,
)
return Cluster(cluster_config)

Expand Down Expand Up @@ -670,7 +669,7 @@ def get_current_namespace(): # pragma: no cover
return None


def get_cluster(cluster_name: str, namespace: str = "default", ingress_domain=None):
def get_cluster(cluster_name: str, namespace: str = "default"):
try:
config_check()
api_instance = client.CustomObjectsApi(api_config_handler())
Expand All @@ -686,9 +685,7 @@ def get_cluster(cluster_name: str, namespace: str = "default", ingress_domain=No
for rc in rcs["items"]:
if rc["metadata"]["name"] == cluster_name:
mcad = _check_aw_exists(cluster_name, namespace)
return Cluster.from_k8_cluster_object(
rc, mcad=mcad, ingress_domain=ingress_domain
)
return Cluster.from_k8_cluster_object(rc, mcad=mcad)
raise FileNotFoundError(
f"Cluster {cluster_name} is not found in {namespace} namespace"
)
Expand Down
7 changes: 4 additions & 3 deletions tests/unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1787,9 +1787,11 @@ def test_get_cluster(mocker):
"kubernetes.client.CustomObjectsApi.list_namespaced_custom_object",
side_effect=get_ray_obj,
)
cluster = get_cluster(
cluster_name="quicktest", ingress_domain="apps.cluster.awsroute.org"
mocker.patch(
"codeflare_sdk.utils.generate_yaml.is_openshift_cluster",
return_value=True,
)
cluster = get_cluster(cluster_name="quicktest")
cluster_config = cluster.config
assert cluster_config.name == "quicktest" and cluster_config.namespace == "ns"
assert (
Expand All @@ -1800,7 +1802,6 @@ def test_get_cluster(mocker):
assert cluster_config.min_memory == 2 and cluster_config.max_memory == 2
assert cluster_config.num_gpus == 0
assert cluster_config.instascale
assert cluster_config.ingress_domain == "apps.cluster.awsroute.org"
assert (
cluster_config.image
== "ghcr.io/foundation-model-stack/base:ray2.1.0-py38-gpu-pytorch1.12.0cu116-20221213-193103"
Expand Down

0 comments on commit dce93f7

Please sign in to comment.