Skip to content

Commit

Permalink
fix-scheduling-spec
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelClifford committed Aug 29, 2023
1 parent 89e6c5b commit 477d7f9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
2 changes: 0 additions & 2 deletions src/codeflare_sdk/templates/base-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ metadata:
orderedinstance: "m4.xlarge_g4dn.xlarge"
spec:
priority: 9
schedulingSpec:
minAvailable: 3
resources:
Items: []
GenericItems:
Expand Down
15 changes: 7 additions & 8 deletions src/codeflare_sdk/utils/generate_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,18 @@ def update_labels(yaml, instascale, instance_types):
metadata.pop("labels")


def update_priority(item, dispatch_priority):
def update_priority(yaml, item, workers, dispatch_priority):
if dispatch_priority is not None:
head = item.get("generictemplate").get("spec").get("headGroupSpec")
worker = item.get("generictemplate").get("spec").get("workerGroupSpecs")[0]
head["template"]["spec"]["priorityClassName"] = dispatch_priority
worker["template"]["spec"]["priorityClassName"] = dispatch_priority
update_scheduling_spec(yaml,workers)

def update_scheduling_spec(yaml, workers):
spec = yaml.get("spec")
spec["schedulingSpec"]={"minAvailable":""}
spec["schedulingSpec"]["minAvailable"] = workers + 1

def update_custompodresources(
item, min_cpu, max_cpu, min_memory, max_memory, gpu, workers
Expand Down Expand Up @@ -183,11 +188,6 @@ def update_resources(spec, min_cpu, max_cpu, min_memory, max_memory, gpu):
limits["nvidia.com/gpu"] = gpu


def update_scheduling_spec(yaml, workers):
spec = yaml.get("spec")
spec["schedulingSpec"]["minAvailable"] = workers + 1


def update_nodes(
item,
appwrapper_name,
Expand Down Expand Up @@ -368,8 +368,7 @@ def generate_appwrapper(
route_item = resources["resources"].get("GenericItems")[1]
update_names(user_yaml, item, appwrapper_name, cluster_name, namespace)
update_labels(user_yaml, instascale, instance_types)
update_priority(item, dispatch_priority)
update_scheduling_spec(user_yaml, workers)
update_priority(user_yaml, item, workers, dispatch_priority)
update_custompodresources(
item, min_cpu, max_cpu, min_memory, max_memory, gpu, workers
)
Expand Down

0 comments on commit 477d7f9

Please sign in to comment.