Skip to content

Commit

Permalink
prep
Browse files Browse the repository at this point in the history
  • Loading branch information
oksanabaza committed May 28, 2024
1 parent 5a7b57f commit 981c312
Showing 1 changed file with 44 additions and 2 deletions.
46 changes: 44 additions & 2 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 kubernetes.client.rest import ApiException


def read_template(template):
Expand Down Expand Up @@ -307,6 +308,32 @@ def get_default_kueue_name(namespace: str):
"Default Local Queue with kueue.x-k8s.io/default-queue: true annotation not found please create a default Local Queue or provide the local_queue name in Cluster Configuration"
)

# test function

# def _throw_for_no_raycluster( user_yaml: dict,
# output_file_name: str,
# namespace: str,
# local_queue: Optional[str],
# labels: dict,):
# api_instance = client.CustomObjectsApi(api_config_handler())
# print('hello')
# # try:
# # api_instance.list_namespaced_custom_object(
# # group="kueue.x-k8s.io",
# # version="v1",
# # namespace=namespace,
# # plural="localqueues",
# # )
# # except ApiException as e:
# # if e.status == 404:
# # raise RuntimeError(
# # "RayCluster CustomResourceDefinition unavailable contact your administrator."
# # )
# # else:
# # raise RuntimeError(
# # "Failed to get RayCluster CustomResourceDefinition: " + str(e)
# # )


def local_queue_exists(namespace: str, local_queue_name: str):
# get all local queues in the namespace
Expand Down Expand Up @@ -341,6 +368,12 @@ def write_components(
os.makedirs(directory_path)

components = user_yaml.get("spec", "resources")["resources"].get("GenericItems")
# check if RayCluster CustomResourceDefinition exists if not throw RuntimeError
# _throw_for_no_raycluster()
# if local_queue is None:
# print(
# "Kueue is not installed or won't be used. The absence of CRDs may lack the necessary functionality."
# )
open(output_file_name, "w").close()
lq_name = local_queue or get_default_kueue_name(namespace)
cluster_labels = labels
Expand All @@ -367,22 +400,31 @@ def write_components(
)
print(f"Written to: {output_file_name}")


def load_components(
user_yaml: dict,
name: str,
namespace: str,
local_queue: Optional[str],
labels: dict,
labels: dict
):
component_list = []
components = user_yaml.get("spec", "resources")["resources"].get("GenericItems")
lq_name = local_queue or get_default_kueue_name(namespace)
cluster_labels = labels
<<<<<<< HEAD
if not local_queue_exists(namespace, lq_name):
raise ValueError(
"local_queue provided does not exist or is not in this namespace. Please provide the correct local_queue name in Cluster Configuration"
)
=======

# _throw_for_no_raycluster()

# if local_queue is None:
# print(
# "Kueue is not installed or won't be used. The absence of CRDs may lack the necessary functionality."
# )
>>>>>>> 1d38c8d (prep)
for component in components:
if "generictemplate" in component:
if (
Expand Down

0 comments on commit 981c312

Please sign in to comment.