Skip to content

Commit 53176a0

Browse files
committed
RHOAIENG-8098 - ClusterConfiguration can be patched
1 parent c51ab98 commit 53176a0

File tree

4 files changed

+7
-0
lines changed

4 files changed

+7
-0
lines changed

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ cryptography = "40.0.2"
3030
executing = "1.2.0"
3131
pydantic = "< 2"
3232
ipywidgets = "8.1.2"
33+
mergedeep = "1.3.4"
3334

3435
[tool.poetry.group.docs]
3536
optional = true

src/codeflare_sdk/cluster/cluster.py

+2
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ def create_app_wrapper(self):
145145
gpu = self.config.num_gpus
146146
workers = self.config.num_workers
147147
template = self.config.template
148+
template_update_dict = self.config.template_update_dict
148149
image = self.config.image
149150
appwrapper = self.config.appwrapper
150151
env = self.config.envs
@@ -176,6 +177,7 @@ def create_app_wrapper(self):
176177
labels=labels,
177178
volumes=volumes,
178179
volume_mounts=volume_mounts,
180+
template_update_dict=template_update_dict,
179181
)
180182

181183
# creates a new cluster with the provided or default spec

src/codeflare_sdk/cluster/config.py

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class ClusterConfiguration:
4646
max_memory: typing.Union[int, str] = 2
4747
num_gpus: int = 0
4848
template: str = f"{dir}/templates/base-template.yaml"
49+
template_update_dict = {}
4950
appwrapper: bool = False
5051
envs: dict = field(default_factory=dict)
5152
image: str = ""

src/codeflare_sdk/utils/generate_yaml.py

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from os import urandom
3131
from base64 import b64encode
3232
from urllib3.util import parse_url
33+
from mergedeep import merge
3334

3435

3536
def read_template(template):
@@ -300,8 +301,10 @@ def generate_appwrapper(
300301
labels,
301302
volumes: list[client.V1Volume],
302303
volume_mounts: list[client.V1VolumeMount],
304+
template_update_dict={},
303305
):
304306
cluster_yaml = read_template(template)
307+
cluster_yaml = merge(cluster_yaml, template_update_dict)
305308
appwrapper_name, cluster_name = gen_names(name)
306309
update_names(cluster_yaml, cluster_name, namespace)
307310
update_nodes(

0 commit comments

Comments
 (0)