Skip to content

Commit

Permalink
Added component generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxusmusti committed Sep 25, 2023
1 parent 54a5a12 commit 29cd61e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/codeflare_sdk/cluster/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ def create_app_wrapper(self):

# Before attempting to create the cluster AW, let's evaluate the ClusterConfig
if self.config.dispatch_priority:
if not self.config.mcad:
raise ValueError(
"Invalid Cluster Configuration, cannot have dispatch priority without MCAD"
)
priority_val = self.evaluate_dispatch_priority()
if priority_val == None:
raise ValueError(
Expand All @@ -121,6 +125,7 @@ def create_app_wrapper(self):
template = self.config.template
image = self.config.image
instascale = self.config.instascale
mcad = self.config.mcad
instance_types = self.config.machine_types
env = self.config.envs
local_interactive = self.config.local_interactive
Expand All @@ -141,6 +146,7 @@ def create_app_wrapper(self):
template=template,
image=image,
instascale=instascale,
mcad=mcad,
instance_types=instance_types,
env=env,
local_interactive=local_interactive,
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:
num_gpus: int = 0
template: str = f"{dir}/templates/base-template.yaml"
instascale: bool = False
mcad: bool = True
envs: dict = field(default_factory=dict)
image: str = "quay.io/project-codeflare/ray:2.5.0-py38-cu116"
local_interactive: bool = False
Expand Down
18 changes: 17 additions & 1 deletion src/codeflare_sdk/utils/generate_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,18 @@ def write_user_appwrapper(user_yaml, output_file_name):
print(f"Written to: {output_file_name}")


def write_components(user_yaml, output_file_name):
components = user_yaml.get("spec", "resources")["resources"].get("GenericItems")
open(output_file_name, "w").close()
with open(output_file_name, "a") as outfile:
for component in components:
if "generictemplate" in component:
yaml.dump(
component["generictemplate"], outfile, default_flow_style=False
)
print(f"Written to: {output_file_name}")


def generate_appwrapper(
name: str,
namespace: str,
Expand All @@ -384,6 +396,7 @@ def generate_appwrapper(
template: str,
image: str,
instascale: bool,
mcad: bool,
instance_types: list,
env,
local_interactive: bool,
Expand Down Expand Up @@ -434,5 +447,8 @@ def generate_appwrapper(
else:
disable_raycluster_tls(resources["resources"])
outfile = appwrapper_name + ".yaml"
write_user_appwrapper(user_yaml, outfile)
if not mcad:
write_components(user_yaml, outfile)
else:
write_user_appwrapper(user_yaml, outfile)
return outfile

0 comments on commit 29cd61e

Please sign in to comment.