Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert Custom Volumes/VolumeMounts #567

Merged
merged 2 commits into from
Jun 21, 2024
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
4 changes: 0 additions & 4 deletions src/codeflare_sdk/cluster/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ def create_app_wrapper(self):
write_to_file = self.config.write_to_file
local_queue = self.config.local_queue
labels = self.config.labels
volumes = self.config.volumes
volume_mounts = self.config.volume_mounts
return generate_appwrapper(
name=name,
namespace=namespace,
Expand All @@ -174,8 +172,6 @@ def create_app_wrapper(self):
write_to_file=write_to_file,
local_queue=local_queue,
labels=labels,
volumes=volumes,
volume_mounts=volume_mounts,
)

# creates a new cluster with the provided or default spec
Expand Down
2 changes: 0 additions & 2 deletions src/codeflare_sdk/cluster/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ class ClusterConfiguration:
write_to_file: bool = False
verify_tls: bool = True
labels: dict = field(default_factory=dict)
volumes: list = field(default_factory=list)
volume_mounts: list = field(default_factory=list)

def __post_init__(self):
if not self.verify_tls:
Expand Down
22 changes: 0 additions & 22 deletions src/codeflare_sdk/utils/generate_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,6 @@ def update_image_pull_secrets(spec, image_pull_secrets):
]


def update_volume_mounts(spec, volume_mounts: list):
containers = spec.get("containers")
for volume_mount in volume_mounts:
for container in containers:
volumeMount = client.ApiClient().sanitize_for_serialization(volume_mount)
container["volumeMounts"].append(volumeMount)


def update_volumes(spec, volumes: list):
for volume in volumes:
new_volume = client.ApiClient().sanitize_for_serialization(volume)
spec["volumes"].append(new_volume)


def update_env(spec, env):
containers = spec.get("containers")
for container in containers:
Expand Down Expand Up @@ -150,8 +136,6 @@ def update_nodes(
head_cpus,
head_memory,
head_gpus,
volumes,
volume_mounts,
):
head = cluster_yaml.get("spec").get("headGroupSpec")
head["rayStartParams"]["num-gpus"] = str(int(head_gpus))
Expand All @@ -166,8 +150,6 @@ def update_nodes(

for comp in [head, worker]:
spec = comp.get("template").get("spec")
update_volume_mounts(spec, volume_mounts)
update_volumes(spec, volumes)
update_image_pull_secrets(spec, image_pull_secrets)
update_image(spec, image)
update_env(spec, env)
Expand Down Expand Up @@ -298,8 +280,6 @@ def generate_appwrapper(
write_to_file: bool,
local_queue: Optional[str],
labels,
volumes: list[client.V1Volume],
volume_mounts: list[client.V1VolumeMount],
):
cluster_yaml = read_template(template)
appwrapper_name, cluster_name = gen_names(name)
Expand All @@ -319,8 +299,6 @@ def generate_appwrapper(
head_cpus,
head_memory,
head_gpus,
volumes,
volume_mounts,
)
augment_labels(cluster_yaml, labels)
notebook_annotations(cluster_yaml)
Expand Down
186 changes: 0 additions & 186 deletions tests/unit-test-volume-cluster.yaml

This file was deleted.

62 changes: 0 additions & 62 deletions tests/unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,68 +444,6 @@ def test_default_cluster_creation(mocker):
assert cluster.config.namespace == "opendatahub"


def test_cluster_with_custom_volumes(mocker):
mocker.patch("kubernetes.client.ApisApi.get_api_versions")
mocker.patch(
"codeflare_sdk.cluster.cluster.get_current_namespace",
return_value="opendatahub",
)
mocker.patch(
"kubernetes.client.CustomObjectsApi.list_namespaced_custom_object",
return_value=get_local_queue("kueue.x-k8s.io", "v1beta1", "ns", "localqueues"),
)

from kubernetes.client import (
V1Volume,
V1VolumeMount,
V1EmptyDirVolumeSource,
V1ConfigMapVolumeSource,
V1KeyToPath,
V1SecretVolumeSource,
)

volume_mounts = [
V1VolumeMount(mount_path="/home/ray/test1", name="test"),
V1VolumeMount(
mount_path="/home/ray/test2",
name="test2",
),
V1VolumeMount(
mount_path="/home/ray/test2",
name="test3",
),
]

volumes = [
V1Volume(
name="test",
empty_dir=V1EmptyDirVolumeSource(size_limit="500Gi"),
),
V1Volume(
name="test2",
config_map=V1ConfigMapVolumeSource(
name="config-map-test",
items=[V1KeyToPath(key="test", path="/home/ray/test2/data.txt")],
),
),
V1Volume(name="test3", secret=V1SecretVolumeSource(secret_name="test-secret")),
]

test_config = ClusterConfiguration(
name="unit-test-volume-cluster",
image="quay.io/project-codeflare/ray:2.20.0-py39-cu118",
volume_mounts=volume_mounts,
volumes=volumes,
)
cluster = Cluster(test_config)
test_rc = yaml.load(cluster.app_wrapper_yaml, Loader=yaml.FullLoader)
with open(
f"{parent}/tests/unit-test-volume-cluster.yaml",
) as f:
volume_rc = yaml.load(f, Loader=yaml.FullLoader)
assert test_rc == volume_rc


def test_gen_names_with_name(mocker):
mocker.patch.object(
uuid, "uuid4", return_value=uuid.UUID("00000000-0000-0000-0000-000000000001")
Expand Down