diff --git a/docs/detailed-documentation/cluster/cluster.html b/docs/detailed-documentation/cluster/cluster.html index eed1e1544..efb6ccfed 100644 --- a/docs/detailed-documentation/cluster/cluster.html +++ b/docs/detailed-documentation/cluster/cluster.html @@ -50,6 +50,7 @@
codeflare_sdk.cluster.cluster
codeflare_sdk.cluster.cluster
codeflare_sdk.cluster.cluster
codeflare_sdk.cluster.cluster
codeflare_sdk.cluster.cluster
codeflare_sdk.cluster.cluster
codeflare_sdk.cluster.cluster
codeflare_sdk.cluster.config
codeflare_sdk.cluster.config
codeflare_sdk.cluster.config
class ClusterConfiguration
-(name: str, namespace: str = None, head_info: list = <factory>, head_cpus: int = 2, head_memory: int = 8, head_gpus: int = 0, machine_types: list = <factory>, min_cpus: int = 1, max_cpus: int = 1, num_workers: int = 1, min_memory: int = 2, max_memory: int = 2, num_gpus: int = 0, template: str = '/home/runner/work/codeflare-sdk/codeflare-sdk/src/codeflare_sdk/templates/base-template.yaml', instascale: bool = False, mcad: bool = False, envs: dict = <factory>, image: str = '', image_pull_secrets: list = <factory>, dispatch_priority: str = None, write_to_file: bool = False, verify_tls: bool = True, local_queue: str = None)
+(name: str, namespace: str = None, head_info: list = <factory>, head_cpus: Union[int, str] = 2, head_memory: Union[int, str] = 8, head_gpus: int = 0, machine_types: list = <factory>, min_cpus: Union[int, str] = 1, max_cpus: Union[int, str] = 1, num_workers: int = 1, min_memory: Union[int, str] = 2, max_memory: Union[int, str] = 2, num_gpus: int = 0, template: str = '/home/runner/work/codeflare-sdk/codeflare-sdk/src/codeflare_sdk/templates/base-template.yaml', instascale: bool = False, mcad: bool = False, envs: dict = <factory>, image: str = '', image_pull_secrets: list = <factory>, dispatch_priority: str = None, write_to_file: bool = False, verify_tls: bool = True, labels: dict = <factory>, local_queue: str = None)
This dataclass is used to specify resource requirements and other details, and @@ -124,15 +144,15 @@
var head_cpus : int
var head_cpus : Union[int, str]
var head_memory : int
var head_memory : Union[int, str]
var labels : dict
var local_queue : str
var max_cpus : int
var max_cpus : Union[int, str]
var max_memory : int
var max_memory : Union[int, str]
var min_cpus : int
var min_cpus : Union[int, str]
var min_memory : int
var min_memory : Union[int, str]
image
image_pull_secrets
instascale
labels
local_queue
machine_types
max_cpus
codeflare_sdk.utils.generate_yaml
codeflare_sdk.utils.generate_yaml
codeflare_sdk.utils.generate_yaml
codeflare_sdk.utils.generate_yaml
codeflare_sdk.utils.generate_yaml
codeflare_sdk.utils.generate_yaml
codeflare_sdk.utils.generate_yaml
codeflare_sdk.utils.generate_yaml
codeflare_sdk.utils.generate_yaml
codeflare_sdk.utils.generate_yaml
-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, instascale: bool, mcad: bool, instance_types: list, env, image_pull_secrets: list, dispatch_priority: str, priority_val: int, write_to_file: bool, verify_tls: bool, local_queue: Optional[str])
+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, instascale: bool, mcad: bool, instance_types: list, env, image_pull_secrets: list, dispatch_priority: str, priority_val: int, write_to_file: bool, verify_tls: bool, local_queue: Optional[str], labels)
-def load_components(user_yaml: dict, name: str, namespace: str, local_queue: Optional[str])
+def load_components(user_yaml: dict, name: str, namespace: str, local_queue: Optional[str], labels: dict)
def load_components(
- user_yaml: dict, name: str, namespace: str, local_queue: Optional[str]
+ user_yaml: dict,
+ name: str,
+ namespace: str,
+ local_queue: Optional[str],
+ 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
for component in components:
if "generictemplate" in component:
if (
@@ -740,6 +759,7 @@ Functions
]
labels = component["generictemplate"]["metadata"]["labels"]
labels.update({"kueue.x-k8s.io/queue-name": lq_name})
+ labels.update(cluster_labels)
component_list.append(component["generictemplate"])
resources = "---\n" + "---\n".join(
@@ -819,8 +839,8 @@ Functions
# Leave head node resources as template default
resource["requests"]["cpu"] = head_cpus
resource["limits"]["cpu"] = head_cpus
- resource["requests"]["memory"] = str(head_memory) + "G"
- resource["limits"]["memory"] = str(head_memory) + "G"
+ resource["requests"]["memory"] = head_memory
+ resource["limits"]["memory"] = head_memory
resource["requests"]["nvidia.com/gpu"] = head_gpus
resource["limits"]["nvidia.com/gpu"] = head_gpus
@@ -837,9 +857,9 @@ Functions
resource[k][spec] = min_cpu
if spec == "memory":
if k == "limits":
- resource[k][spec] = str(max_memory) + "G"
+ resource[k][spec] = max_memory
else:
- resource[k][spec] = str(min_memory) + "G"
+ resource[k][spec] = min_memory
if spec == "nvidia.com/gpu":
if i == 0:
resource[k][spec] = 0
@@ -1037,17 +1057,17 @@ Functions
requests = resource.get("resources").get("requests")
if requests is not None:
requests["cpu"] = min_cpu
- requests["memory"] = str(min_memory) + "G"
+ requests["memory"] = min_memory
requests["nvidia.com/gpu"] = gpu
limits = resource.get("resources").get("limits")
if limits is not None:
limits["cpu"] = max_cpu
- limits["memory"] = str(max_memory) + "G"
+ limits["memory"] = max_memory
limits["nvidia.com/gpu"] = gpu
-def write_components(user_yaml: dict, output_file_name: str, namespace: str, local_queue: Optional[str])
+def write_components(user_yaml: dict, output_file_name: str, namespace: str, local_queue: Optional[str], labels: dict)
def write_components(
- user_yaml: dict, output_file_name: str, namespace: str, local_queue: Optional[str]
+ user_yaml: dict,
+ output_file_name: str,
+ namespace: str,
+ local_queue: Optional[str],
+ labels: dict,
):
# Create the directory if it doesn't exist
directory_path = os.path.dirname(output_file_name)
@@ -1066,6 +1090,7 @@ Functions
components = user_yaml.get("spec", "resources")["resources"].get("GenericItems")
open(output_file_name, "w").close()
lq_name = local_queue or get_default_kueue_name(namespace)
+ cluster_labels = labels
with open(output_file_name, "a") as outfile:
for component in components:
if "generictemplate" in component:
@@ -1078,6 +1103,7 @@ Functions
]
labels = component["generictemplate"]["metadata"]["labels"]
labels.update({"kueue.x-k8s.io/queue-name": lq_name})
+ labels.update(cluster_labels)
outfile.write("---\n")
yaml.dump(
component["generictemplate"], outfile, default_flow_style=False
diff --git a/docs/detailed-documentation/utils/pretty_print.html b/docs/detailed-documentation/utils/pretty_print.html
index e7c108256..2e7a69b81 100644
--- a/docs/detailed-documentation/utils/pretty_print.html
+++ b/docs/detailed-documentation/utils/pretty_print.html
@@ -167,7 +167,7 @@ Module codeflare_sdk.utils.pretty_print
name = cluster.name
dashboard = cluster.dashboard
workers = str(cluster.workers)
- memory = str(cluster.worker_mem_min) + "~" + str(cluster.worker_mem_max)
+ memory = f"{cluster.worker_mem_min}~{cluster.worker_mem_max}"
cpu = str(cluster.worker_cpu)
gpu = str(cluster.worker_gpu)
@@ -345,7 +345,7 @@ Functions
name = cluster.name
dashboard = cluster.dashboard
workers = str(cluster.workers)
- memory = str(cluster.worker_mem_min) + "~" + str(cluster.worker_mem_max)
+ memory = f"{cluster.worker_mem_min}~{cluster.worker_mem_max}"
cpu = str(cluster.worker_cpu)
gpu = str(cluster.worker_gpu)