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

RHOAIENG-8098 - ClusterConfiguration can be patched #564

Closed
Closed
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
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ cryptography = "40.0.2"
executing = "1.2.0"
pydantic = "< 2"
ipywidgets = "8.1.2"
mergedeep = "1.3.4"

[tool.poetry.group.docs]
optional = true
Expand Down
2 changes: 2 additions & 0 deletions src/codeflare_sdk/cluster/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ def create_app_wrapper(self):
gpu = self.config.num_gpus
workers = self.config.num_workers
template = self.config.template
template_update_dict = self.config.template_update_dict
image = self.config.image
appwrapper = self.config.appwrapper
env = self.config.envs
Expand Down Expand Up @@ -176,6 +177,7 @@ def create_app_wrapper(self):
labels=labels,
volumes=volumes,
volume_mounts=volume_mounts,
template_update_dict=template_update_dict,
)

# creates a new cluster with the provided or default spec
Expand Down
1 change: 1 addition & 0 deletions src/codeflare_sdk/cluster/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class ClusterConfiguration:
max_memory: typing.Union[int, str] = 2
num_gpus: int = 0
template: str = f"{dir}/templates/base-template.yaml"
template_update_dict = {}
appwrapper: bool = False
envs: dict = field(default_factory=dict)
image: str = ""
Expand Down
3 changes: 3 additions & 0 deletions src/codeflare_sdk/utils/generate_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from os import urandom
from base64 import b64encode
from urllib3.util import parse_url
from mergedeep import merge


def read_template(template):
Expand Down Expand Up @@ -300,8 +301,10 @@ def generate_appwrapper(
labels,
volumes: list[client.V1Volume],
volume_mounts: list[client.V1VolumeMount],
template_update_dict={},
):
cluster_yaml = read_template(template)
cluster_yaml = merge(cluster_yaml, template_update_dict)
appwrapper_name, cluster_name = gen_names(name)
update_names(cluster_yaml, cluster_name, namespace)
update_nodes(
Expand Down
Loading