From a03c72f6f5f7de517ec6e8c5164d3d43e474aaa0 Mon Sep 17 00:00:00 2001 From: codeflare-machine-account Date: Fri, 21 Jun 2024 16:55:29 +0000 Subject: [PATCH] Changes in docs for release: v0.16.4 --- .../cluster/awload.html | 6 +- .../cluster/cluster.html | 30 +- .../cluster/config.html | 3 +- .../detailed-documentation/cluster/model.html | 6 +- docs/detailed-documentation/job/ray_jobs.html | 4 +- .../utils/generate_yaml.html | 402 +++++++----------- 6 files changed, 174 insertions(+), 277 deletions(-) diff --git a/docs/detailed-documentation/cluster/awload.html b/docs/detailed-documentation/cluster/awload.html index 297ebc02c..c77ac0e7c 100644 --- a/docs/detailed-documentation/cluster/awload.html +++ b/docs/detailed-documentation/cluster/awload.html @@ -61,7 +61,7 @@

Module codeflare_sdk.cluster.awload

class AWManager: """ An object for submitting and removing existing AppWrapper yamls - to be added to the MCAD queue. + to be added to the Kueue localqueue. """ def __init__(self, filename: str) -> None: @@ -145,7 +145,7 @@

Classes

An object for submitting and removing existing AppWrapper yamls -to be added to the MCAD queue.

+to be added to the Kueue localqueue.

Create the AppWrapper Manager object by passing in an AppWrapper yaml file

@@ -155,7 +155,7 @@

Classes

class AWManager:
     """
     An object for submitting and removing existing AppWrapper yamls
-    to be added to the MCAD queue.
+    to be added to the Kueue localqueue.
     """
 
     def __init__(self, filename: str) -> None:
diff --git a/docs/detailed-documentation/cluster/cluster.html b/docs/detailed-documentation/cluster/cluster.html
index 7544b4d58..1e49cf6d6 100644
--- a/docs/detailed-documentation/cluster/cluster.html
+++ b/docs/detailed-documentation/cluster/cluster.html
@@ -179,11 +179,9 @@ 

Module codeflare_sdk.cluster.cluster

template = self.config.template image = self.config.image appwrapper = self.config.appwrapper - instance_types = self.config.machine_types env = self.config.envs image_pull_secrets = self.config.image_pull_secrets write_to_file = self.config.write_to_file - verify_tls = self.config.verify_tls local_queue = self.config.local_queue labels = self.config.labels return generate_appwrapper( @@ -201,11 +199,9 @@

Module codeflare_sdk.cluster.cluster

template=template, image=image, appwrapper=appwrapper, - instance_types=instance_types, env=env, image_pull_secrets=image_pull_secrets, write_to_file=write_to_file, - verify_tls=verify_tls, local_queue=local_queue, labels=labels, ) @@ -213,8 +209,8 @@

Module codeflare_sdk.cluster.cluster

# creates a new cluster with the provided or default spec def up(self): """ - Applies the AppWrapper yaml, pushing the resource request onto - the MCAD queue. + Applies the Cluster yaml, pushing the resource request onto + the Kueue localqueue. """ # check if RayCluster CustomResourceDefinition exists if not throw RuntimeError @@ -1229,11 +1225,9 @@

Classes

template = self.config.template image = self.config.image appwrapper = self.config.appwrapper - instance_types = self.config.machine_types env = self.config.envs image_pull_secrets = self.config.image_pull_secrets write_to_file = self.config.write_to_file - verify_tls = self.config.verify_tls local_queue = self.config.local_queue labels = self.config.labels return generate_appwrapper( @@ -1251,11 +1245,9 @@

Classes

template=template, image=image, appwrapper=appwrapper, - instance_types=instance_types, env=env, image_pull_secrets=image_pull_secrets, write_to_file=write_to_file, - verify_tls=verify_tls, local_queue=local_queue, labels=labels, ) @@ -1263,8 +1255,8 @@

Classes

# creates a new cluster with the provided or default spec def up(self): """ - Applies the AppWrapper yaml, pushing the resource request onto - the MCAD queue. + Applies the Cluster yaml, pushing the resource request onto + the Kueue localqueue. """ # check if RayCluster CustomResourceDefinition exists if not throw RuntimeError @@ -1776,11 +1768,9 @@

Methods

template = self.config.template image = self.config.image appwrapper = self.config.appwrapper - instance_types = self.config.machine_types env = self.config.envs image_pull_secrets = self.config.image_pull_secrets write_to_file = self.config.write_to_file - verify_tls = self.config.verify_tls local_queue = self.config.local_queue labels = self.config.labels return generate_appwrapper( @@ -1798,11 +1788,9 @@

Methods

template=template, image=image, appwrapper=appwrapper, - instance_types=instance_types, env=env, image_pull_secrets=image_pull_secrets, write_to_file=write_to_file, - verify_tls=verify_tls, local_queue=local_queue, labels=labels, )
@@ -1974,7 +1962,7 @@

Methods

-def list_jobs(self) ‑> List[~T] +def list_jobs(self) ‑> List

This method accesses the head ray node in your cluster and lists the running jobs.

@@ -2090,16 +2078,16 @@

Methods

def up(self)
-

Applies the AppWrapper yaml, pushing the resource request onto -the MCAD queue.

+

Applies the Cluster yaml, pushing the resource request onto +the Kueue localqueue.

Expand source code
def up(self):
     """
-    Applies the AppWrapper yaml, pushing the resource request onto
-    the MCAD queue.
+    Applies the Cluster yaml, pushing the resource request onto
+    the Kueue localqueue.
     """
 
     # check if RayCluster CustomResourceDefinition exists if not throw RuntimeError
diff --git a/docs/detailed-documentation/cluster/config.html b/docs/detailed-documentation/cluster/config.html
index 4ce9dcdd0..60b6dc95f 100644
--- a/docs/detailed-documentation/cluster/config.html
+++ b/docs/detailed-documentation/cluster/config.html
@@ -133,7 +133,8 @@ 

Classes

Expand source code -
class ClusterConfiguration:
+
@dataclass
+class ClusterConfiguration:
     """
     This dataclass is used to specify resource requirements and other details, and
     is passed in as an argument when creating a Cluster object.
diff --git a/docs/detailed-documentation/cluster/model.html b/docs/detailed-documentation/cluster/model.html
index d69357e18..e47808e4a 100644
--- a/docs/detailed-documentation/cluster/model.html
+++ b/docs/detailed-documentation/cluster/model.html
@@ -146,7 +146,8 @@ 

Classes

Expand source code -
class AppWrapper:
+
@dataclass
+class AppWrapper:
     """
     For storing information about an AppWrapper.
     """
@@ -299,7 +300,8 @@ 

Class variables

Expand source code -
class RayCluster:
+
@dataclass
+class RayCluster:
     """
     For storing information about a Ray cluster.
     """
diff --git a/docs/detailed-documentation/job/ray_jobs.html b/docs/detailed-documentation/job/ray_jobs.html
index f0d10cd86..01fa5fb51 100644
--- a/docs/detailed-documentation/job/ray_jobs.html
+++ b/docs/detailed-documentation/job/ray_jobs.html
@@ -191,7 +191,7 @@ 

Classes

class RayJobClient -(address: Optional[str] = None, create_cluster_if_needed: bool = False, cookies: Optional[Dict[str, Any]] = None, metadata: Optional[Dict[str, Any]] = None, headers: Optional[Dict[str, Any]] = None, verify: Union[str, bool, None] = True) +(address: Optional[str] = None, create_cluster_if_needed: bool = False, cookies: Optional[Dict[str, Any]] = None, metadata: Optional[Dict[str, Any]] = None, headers: Optional[Dict[str, Any]] = None, verify: Union[str, bool, ForwardRef(None)] = True)

A class that functions as a wrapper for the Ray Job Submission Client.

@@ -461,7 +461,7 @@

Methods

-def submit_job(self, entrypoint: str, job_id: Optional[str] = None, runtime_env: Optional[Dict[str, Any]] = None, metadata: Optional[Dict[str, str]] = None, submission_id: Optional[str] = None, entrypoint_num_cpus: Union[int, float, None] = None, entrypoint_num_gpus: Union[int, float, None] = None, entrypoint_resources: Optional[Dict[str, float]] = None) ‑> str +def submit_job(self, entrypoint: str, job_id: Optional[str] = None, runtime_env: Optional[Dict[str, Any]] = None, metadata: Optional[Dict[str, str]] = None, submission_id: Optional[str] = None, entrypoint_num_cpus: Union[int, float, ForwardRef(None)] = None, entrypoint_num_gpus: Union[int, float, ForwardRef(None)] = None, entrypoint_resources: Optional[Dict[str, float]] = None) ‑> str

Method for submitting jobs to a Ray Cluster and returning the job id with entrypoint being a mandatory field.

diff --git a/docs/detailed-documentation/utils/generate_yaml.html b/docs/detailed-documentation/utils/generate_yaml.html index 5ee410ce9..1e4217629 100644 --- a/docs/detailed-documentation/utils/generate_yaml.html +++ b/docs/detailed-documentation/utils/generate_yaml.html @@ -108,13 +108,10 @@

Module codeflare_sdk.utils.generate_yaml

return False -def update_names(yaml, item, appwrapper_name, cluster_name, namespace): - metadata = yaml.get("metadata") - metadata["name"] = appwrapper_name - metadata["namespace"] = namespace - lower_meta = item.get("template", {}).get("metadata") - lower_meta["name"] = cluster_name - lower_meta["namespace"] = namespace +def update_names(cluster_yaml, cluster_name, namespace): + meta = cluster_yaml.get("metadata") + meta["name"] = cluster_name + meta["namespace"] = namespace def update_image(spec, image): @@ -156,7 +153,7 @@

Module codeflare_sdk.utils.generate_yaml

def update_nodes( - item, + cluster_yaml, appwrapper_name, min_cpu, max_cpu, @@ -171,48 +168,35 @@

Module codeflare_sdk.utils.generate_yaml

head_memory, head_gpus, ): - if "template" in item.keys(): - head = item.get("template").get("spec").get("headGroupSpec") - head["rayStartParams"]["num-gpus"] = str(int(head_gpus)) - - worker = item.get("template").get("spec").get("workerGroupSpecs")[0] - # Head counts as first worker - worker["replicas"] = workers - worker["minReplicas"] = workers - worker["maxReplicas"] = workers - worker["groupName"] = "small-group-" + appwrapper_name - worker["rayStartParams"]["num-gpus"] = str(int(gpu)) - - for comp in [head, worker]: - spec = comp.get("template").get("spec") - update_image_pull_secrets(spec, image_pull_secrets) - update_image(spec, image) - update_env(spec, env) - if comp == head: - # TODO: Eventually add head node configuration outside of template - update_resources( - spec, head_cpus, head_cpus, head_memory, head_memory, head_gpus - ) - else: - update_resources(spec, min_cpu, max_cpu, min_memory, max_memory, gpu) + head = cluster_yaml.get("spec").get("headGroupSpec") + head["rayStartParams"]["num-gpus"] = str(int(head_gpus)) + + worker = cluster_yaml.get("spec").get("workerGroupSpecs")[0] + # Head counts as first worker + worker["replicas"] = workers + worker["minReplicas"] = workers + worker["maxReplicas"] = workers + worker["groupName"] = "small-group-" + appwrapper_name + worker["rayStartParams"]["num-gpus"] = str(int(gpu)) + + for comp in [head, worker]: + spec = comp.get("template").get("spec") + update_image_pull_secrets(spec, image_pull_secrets) + update_image(spec, image) + update_env(spec, env) + if comp == head: + # TODO: Eventually add head node configuration outside of template + update_resources( + spec, head_cpus, head_cpus, head_memory, head_memory, head_gpus + ) + else: + update_resources(spec, min_cpu, max_cpu, min_memory, max_memory, gpu) def del_from_list_by_name(l: list, target: typing.List[str]) -> list: return [x for x in l if x["name"] not in target] -def write_user_appwrapper(user_yaml, output_file_name): - # Create the directory if it doesn't exist - directory_path = os.path.dirname(output_file_name) - if not os.path.exists(directory_path): - os.makedirs(directory_path) - - with open(output_file_name, "w") as outfile: - yaml.dump(user_yaml, outfile, default_flow_style=False) - - print(f"Written to: {output_file_name}") - - def get_default_kueue_name(namespace: str): # If the local queue is set, use it. Otherwise, try to use the default queue. try: @@ -271,53 +255,40 @@

Module codeflare_sdk.utils.generate_yaml

def augment_labels(item: dict, labels: dict): - if "template" in item: - if not "labels" in item["template"]["metadata"]: - item["template"]["metadata"]["labels"] = {} - item["template"]["metadata"]["labels"].update(labels) + if not "labels" in item["metadata"]: + item["metadata"]["labels"] = {} + item["metadata"]["labels"].update(labels) -def write_components( - user_yaml: dict, - output_file_name: str, -): +def notebook_annotations(item: dict): + nb_prefix = os.environ.get("NB_PREFIX") + if nb_prefix: + if not "annotations" in item["metadata"]: + item["metadata"]["annotations"] = {} + item["metadata"]["annotations"].update( + {"app.kubernetes.io/managed-by": nb_prefix} + ) + + +def wrap_cluster(cluster_yaml: dict, appwrapper_name: str, namespace: str): + return { + "apiVersion": "workload.codeflare.dev/v1beta2", + "kind": "AppWrapper", + "metadata": {"name": appwrapper_name, "namespace": namespace}, + "spec": {"components": [{"template": cluster_yaml}]}, + } + + +def write_user_yaml(user_yaml, output_file_name): # Create the directory if it doesn't exist directory_path = os.path.dirname(output_file_name) if not os.path.exists(directory_path): os.makedirs(directory_path) - components = user_yaml.get("spec", "resources").get("components") - open(output_file_name, "w").close() - with open(output_file_name, "a") as outfile: - for component in components: - if "template" in component: - outfile.write("---\n") - yaml.dump(component["template"], outfile, default_flow_style=False) - print(f"Written to: {output_file_name}") - - -def load_components( - user_yaml: dict, - name: str, -): - component_list = [] - components = user_yaml.get("spec", "resources").get("components") - for component in components: - if "template" in component: - component_list.append(component["template"]) - - resources = "---\n" + "---\n".join( - [yaml.dump(component) for component in component_list] - ) - user_yaml = resources - print(f"Yaml resources loaded for {name}") - return user_yaml - + with open(output_file_name, "w") as outfile: + yaml.dump(user_yaml, outfile, default_flow_style=False) -def load_appwrapper(user_yaml: dict, name: str): - user_yaml = yaml.dump(user_yaml) - print(f"Yaml resources loaded for {name}") - return user_yaml + print(f"Written to: {output_file_name}") def generate_appwrapper( @@ -335,27 +306,17 @@

Module codeflare_sdk.utils.generate_yaml

template: str, image: str, appwrapper: bool, - instance_types: list, env, image_pull_secrets: list, write_to_file: bool, - verify_tls: bool, local_queue: Optional[str], labels, ): - user_yaml = read_template(template) + cluster_yaml = read_template(template) appwrapper_name, cluster_name = gen_names(name) - resources = user_yaml.get("spec", "resources") - item = resources.get("components")[0] - update_names( - user_yaml, - item, - appwrapper_name, - cluster_name, - namespace, - ) + update_names(cluster_yaml, cluster_name, namespace) update_nodes( - item, + cluster_yaml, appwrapper_name, min_cpu, max_cpu, @@ -370,28 +331,25 @@

Module codeflare_sdk.utils.generate_yaml

head_memory, head_gpus, ) + augment_labels(cluster_yaml, labels) + notebook_annotations(cluster_yaml) - augment_labels(item, labels) - - if appwrapper: - add_queue_label(user_yaml, namespace, local_queue) - else: - add_queue_label(item["template"], namespace, local_queue) + user_yaml = ( + wrap_cluster(cluster_yaml, appwrapper_name, namespace) + if appwrapper + else cluster_yaml + ) - directory_path = os.path.expanduser("~/.codeflare/resources/") - outfile = os.path.join(directory_path, appwrapper_name + ".yaml") + add_queue_label(user_yaml, namespace, local_queue) if write_to_file: - if appwrapper: - write_user_appwrapper(user_yaml, outfile) - else: - write_components(user_yaml, outfile) + directory_path = os.path.expanduser("~/.codeflare/resources/") + outfile = os.path.join(directory_path, appwrapper_name + ".yaml") + write_user_yaml(user_yaml, outfile) return outfile else: - if appwrapper: - user_yaml = load_appwrapper(user_yaml, name) - else: - user_yaml = load_components(user_yaml, name) + user_yaml = yaml.dump(user_yaml) + print(f"Yaml resources loaded for {name}") return user_yaml
@@ -432,10 +390,9 @@

Functions

Expand source code
def augment_labels(item: dict, labels: dict):
-    if "template" in item:
-        if not "labels" in item["template"]["metadata"]:
-            item["template"]["metadata"]["labels"] = {}
-    item["template"]["metadata"]["labels"].update(labels)
+ if not "labels" in item["metadata"]: + item["metadata"]["labels"] = {} + item["metadata"]["labels"].update(labels)
@@ -471,7 +428,7 @@

Functions

-def generate_appwrapper(name: str, namespace: str, head_cpus: int, head_memory: int, head_gpus: int, min_cpu: int, max_cpu: int, min_memory: int, max_memory: int, gpu: int, workers: int, template: str, image: str, appwrapper: bool, instance_types: list, env, image_pull_secrets: list, write_to_file: bool, verify_tls: bool, local_queue: Optional[str], labels) +def generate_appwrapper(name: str, namespace: str, head_cpus: int, head_memory: int, head_gpus: int, min_cpu: int, max_cpu: int, min_memory: int, max_memory: int, gpu: int, workers: int, template: str, image: str, appwrapper: bool, env, image_pull_secrets: list, write_to_file: bool, local_queue: Optional[str], labels)
@@ -494,27 +451,17 @@

Functions

template: str, image: str, appwrapper: bool, - instance_types: list, env, image_pull_secrets: list, write_to_file: bool, - verify_tls: bool, local_queue: Optional[str], labels, ): - user_yaml = read_template(template) + cluster_yaml = read_template(template) appwrapper_name, cluster_name = gen_names(name) - resources = user_yaml.get("spec", "resources") - item = resources.get("components")[0] - update_names( - user_yaml, - item, - appwrapper_name, - cluster_name, - namespace, - ) + update_names(cluster_yaml, cluster_name, namespace) update_nodes( - item, + cluster_yaml, appwrapper_name, min_cpu, max_cpu, @@ -529,28 +476,25 @@

Functions

head_memory, head_gpus, ) + augment_labels(cluster_yaml, labels) + notebook_annotations(cluster_yaml) - augment_labels(item, labels) - - if appwrapper: - add_queue_label(user_yaml, namespace, local_queue) - else: - add_queue_label(item["template"], namespace, local_queue) + user_yaml = ( + wrap_cluster(cluster_yaml, appwrapper_name, namespace) + if appwrapper + else cluster_yaml + ) - directory_path = os.path.expanduser("~/.codeflare/resources/") - outfile = os.path.join(directory_path, appwrapper_name + ".yaml") + add_queue_label(user_yaml, namespace, local_queue) if write_to_file: - if appwrapper: - write_user_appwrapper(user_yaml, outfile) - else: - write_components(user_yaml, outfile) + directory_path = os.path.expanduser("~/.codeflare/resources/") + outfile = os.path.join(directory_path, appwrapper_name + ".yaml") + write_user_yaml(user_yaml, outfile) return outfile else: - if appwrapper: - user_yaml = load_appwrapper(user_yaml, name) - else: - user_yaml = load_components(user_yaml, name) + user_yaml = yaml.dump(user_yaml) + print(f"Yaml resources loaded for {name}") return user_yaml
@@ -633,48 +577,6 @@

Functions

return _kube_api_error_handling(e)
-
-def load_appwrapper(user_yaml: dict, name: str) -
-
-
-
- -Expand source code - -
def load_appwrapper(user_yaml: dict, name: str):
-    user_yaml = yaml.dump(user_yaml)
-    print(f"Yaml resources loaded for {name}")
-    return user_yaml
-
-
-
-def load_components(user_yaml: dict, name: str) -
-
-
-
- -Expand source code - -
def load_components(
-    user_yaml: dict,
-    name: str,
-):
-    component_list = []
-    components = user_yaml.get("spec", "resources").get("components")
-    for component in components:
-        if "template" in component:
-            component_list.append(component["template"])
-
-    resources = "---\n" + "---\n".join(
-        [yaml.dump(component) for component in component_list]
-    )
-    user_yaml = resources
-    print(f"Yaml resources loaded for {name}")
-    return user_yaml
-
-
def local_queue_exists(namespace: str, local_queue_name: str)
@@ -704,6 +606,25 @@

Functions

return False +
+def notebook_annotations(item: dict) +
+
+
+
+ +Expand source code + +
def notebook_annotations(item: dict):
+    nb_prefix = os.environ.get("NB_PREFIX")
+    if nb_prefix:
+        if not "annotations" in item["metadata"]:
+            item["metadata"]["annotations"] = {}
+        item["metadata"]["annotations"].update(
+            {"app.kubernetes.io/managed-by": nb_prefix}
+        )
+
+
def read_template(template)
@@ -772,7 +693,7 @@

Functions

-def update_names(yaml, item, appwrapper_name, cluster_name, namespace) +def update_names(cluster_yaml, cluster_name, namespace)
@@ -780,17 +701,14 @@

Functions

Expand source code -
def update_names(yaml, item, appwrapper_name, cluster_name, namespace):
-    metadata = yaml.get("metadata")
-    metadata["name"] = appwrapper_name
-    metadata["namespace"] = namespace
-    lower_meta = item.get("template", {}).get("metadata")
-    lower_meta["name"] = cluster_name
-    lower_meta["namespace"] = namespace
+
def update_names(cluster_yaml, cluster_name, namespace):
+    meta = cluster_yaml.get("metadata")
+    meta["name"] = cluster_name
+    meta["namespace"] = namespace
-def update_nodes(item, appwrapper_name, min_cpu, max_cpu, min_memory, max_memory, gpu, workers, image, env, image_pull_secrets, head_cpus, head_memory, head_gpus) +def update_nodes(cluster_yaml, appwrapper_name, min_cpu, max_cpu, min_memory, max_memory, gpu, workers, image, env, image_pull_secrets, head_cpus, head_memory, head_gpus)
@@ -799,7 +717,7 @@

Functions

Expand source code
def update_nodes(
-    item,
+    cluster_yaml,
     appwrapper_name,
     min_cpu,
     max_cpu,
@@ -814,30 +732,29 @@ 

Functions

head_memory, head_gpus, ): - if "template" in item.keys(): - head = item.get("template").get("spec").get("headGroupSpec") - head["rayStartParams"]["num-gpus"] = str(int(head_gpus)) - - worker = item.get("template").get("spec").get("workerGroupSpecs")[0] - # Head counts as first worker - worker["replicas"] = workers - worker["minReplicas"] = workers - worker["maxReplicas"] = workers - worker["groupName"] = "small-group-" + appwrapper_name - worker["rayStartParams"]["num-gpus"] = str(int(gpu)) - - for comp in [head, worker]: - spec = comp.get("template").get("spec") - update_image_pull_secrets(spec, image_pull_secrets) - update_image(spec, image) - update_env(spec, env) - if comp == head: - # TODO: Eventually add head node configuration outside of template - update_resources( - spec, head_cpus, head_cpus, head_memory, head_memory, head_gpus - ) - else: - update_resources(spec, min_cpu, max_cpu, min_memory, max_memory, gpu)
+ head = cluster_yaml.get("spec").get("headGroupSpec") + head["rayStartParams"]["num-gpus"] = str(int(head_gpus)) + + worker = cluster_yaml.get("spec").get("workerGroupSpecs")[0] + # Head counts as first worker + worker["replicas"] = workers + worker["minReplicas"] = workers + worker["maxReplicas"] = workers + worker["groupName"] = "small-group-" + appwrapper_name + worker["rayStartParams"]["num-gpus"] = str(int(gpu)) + + for comp in [head, worker]: + spec = comp.get("template").get("spec") + update_image_pull_secrets(spec, image_pull_secrets) + update_image(spec, image) + update_env(spec, env) + if comp == head: + # TODO: Eventually add head node configuration outside of template + update_resources( + spec, head_cpus, head_cpus, head_memory, head_memory, head_gpus + ) + else: + update_resources(spec, min_cpu, max_cpu, min_memory, max_memory, gpu)
@@ -864,8 +781,8 @@

Functions

limits["nvidia.com/gpu"] = gpu
-
-def write_components(user_yaml: dict, output_file_name: str) +
+def wrap_cluster(cluster_yaml: dict, appwrapper_name: str, namespace: str)
@@ -873,27 +790,17 @@

Functions

Expand source code -
def write_components(
-    user_yaml: dict,
-    output_file_name: str,
-):
-    # Create the directory if it doesn't exist
-    directory_path = os.path.dirname(output_file_name)
-    if not os.path.exists(directory_path):
-        os.makedirs(directory_path)
-
-    components = user_yaml.get("spec", "resources").get("components")
-    open(output_file_name, "w").close()
-    with open(output_file_name, "a") as outfile:
-        for component in components:
-            if "template" in component:
-                outfile.write("---\n")
-                yaml.dump(component["template"], outfile, default_flow_style=False)
-    print(f"Written to: {output_file_name}")
+
def wrap_cluster(cluster_yaml: dict, appwrapper_name: str, namespace: str):
+    return {
+        "apiVersion": "workload.codeflare.dev/v1beta2",
+        "kind": "AppWrapper",
+        "metadata": {"name": appwrapper_name, "namespace": namespace},
+        "spec": {"components": [{"template": cluster_yaml}]},
+    }
-
-def write_user_appwrapper(user_yaml, output_file_name) +
+def write_user_yaml(user_yaml, output_file_name)
@@ -901,7 +808,7 @@

Functions

Expand source code -
def write_user_appwrapper(user_yaml, output_file_name):
+
def write_user_yaml(user_yaml, output_file_name):
     # Create the directory if it doesn't exist
     directory_path = os.path.dirname(output_file_name)
     if not os.path.exists(directory_path):
@@ -939,9 +846,8 @@ 

Index

  • get_default_kueue_name
  • is_kind_cluster
  • is_openshift_cluster
  • -
  • load_appwrapper
  • -
  • load_components
  • local_queue_exists
  • +
  • notebook_annotations
  • read_template
  • update_env
  • update_image
  • @@ -949,8 +855,8 @@

    Index

  • update_names
  • update_nodes
  • update_resources
  • -
  • write_components
  • -
  • write_user_appwrapper
  • +
  • wrap_cluster
  • +
  • write_user_yaml