Skip to content

Commit 29cd61e

Browse files
committed
Added component generation
1 parent 54a5a12 commit 29cd61e

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

src/codeflare_sdk/cluster/cluster.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ def create_app_wrapper(self):
9999

100100
# Before attempting to create the cluster AW, let's evaluate the ClusterConfig
101101
if self.config.dispatch_priority:
102+
if not self.config.mcad:
103+
raise ValueError(
104+
"Invalid Cluster Configuration, cannot have dispatch priority without MCAD"
105+
)
102106
priority_val = self.evaluate_dispatch_priority()
103107
if priority_val == None:
104108
raise ValueError(
@@ -121,6 +125,7 @@ def create_app_wrapper(self):
121125
template = self.config.template
122126
image = self.config.image
123127
instascale = self.config.instascale
128+
mcad = self.config.mcad
124129
instance_types = self.config.machine_types
125130
env = self.config.envs
126131
local_interactive = self.config.local_interactive
@@ -141,6 +146,7 @@ def create_app_wrapper(self):
141146
template=template,
142147
image=image,
143148
instascale=instascale,
149+
mcad=mcad,
144150
instance_types=instance_types,
145151
env=env,
146152
local_interactive=local_interactive,

src/codeflare_sdk/cluster/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class ClusterConfiguration:
4646
num_gpus: int = 0
4747
template: str = f"{dir}/templates/base-template.yaml"
4848
instascale: bool = False
49+
mcad: bool = True
4950
envs: dict = field(default_factory=dict)
5051
image: str = "quay.io/project-codeflare/ray:2.5.0-py38-cu116"
5152
local_interactive: bool = False

src/codeflare_sdk/utils/generate_yaml.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,18 @@ def write_user_appwrapper(user_yaml, output_file_name):
369369
print(f"Written to: {output_file_name}")
370370

371371

372+
def write_components(user_yaml, output_file_name):
373+
components = user_yaml.get("spec", "resources")["resources"].get("GenericItems")
374+
open(output_file_name, "w").close()
375+
with open(output_file_name, "a") as outfile:
376+
for component in components:
377+
if "generictemplate" in component:
378+
yaml.dump(
379+
component["generictemplate"], outfile, default_flow_style=False
380+
)
381+
print(f"Written to: {output_file_name}")
382+
383+
372384
def generate_appwrapper(
373385
name: str,
374386
namespace: str,
@@ -384,6 +396,7 @@ def generate_appwrapper(
384396
template: str,
385397
image: str,
386398
instascale: bool,
399+
mcad: bool,
387400
instance_types: list,
388401
env,
389402
local_interactive: bool,
@@ -434,5 +447,8 @@ def generate_appwrapper(
434447
else:
435448
disable_raycluster_tls(resources["resources"])
436449
outfile = appwrapper_name + ".yaml"
437-
write_user_appwrapper(user_yaml, outfile)
450+
if not mcad:
451+
write_components(user_yaml, outfile)
452+
else:
453+
write_user_appwrapper(user_yaml, outfile)
438454
return outfile

0 commit comments

Comments
 (0)