Skip to content

Commit 8fd9f5f

Browse files
committed
remove dispatch_priority (not supported by v1beta2 AppWrapper)
1 parent 3c84091 commit 8fd9f5f

File tree

5 files changed

+3
-284
lines changed

5 files changed

+3
-284
lines changed

src/codeflare_sdk/cluster/cluster.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -103,26 +103,6 @@ def job_client(self):
103103
)
104104
return self._job_submission_client
105105

106-
def evaluate_dispatch_priority(self):
107-
priority_class = self.config.dispatch_priority
108-
109-
try:
110-
config_check()
111-
api_instance = client.CustomObjectsApi(api_config_handler())
112-
priority_classes = api_instance.list_cluster_custom_object(
113-
group="scheduling.k8s.io",
114-
version="v1",
115-
plural="priorityclasses",
116-
)
117-
except Exception as e: # pragma: no cover
118-
return _kube_api_error_handling(e)
119-
120-
for pc in priority_classes["items"]:
121-
if pc["metadata"]["name"] == priority_class:
122-
return pc["value"]
123-
print(f"Priority class {priority_class} is not available in the cluster")
124-
return None
125-
126106
def validate_image_config(self):
127107
"""
128108
Validates that the image configuration is not empty.
@@ -152,18 +132,6 @@ def create_app_wrapper(self):
152132
self.validate_image_config()
153133

154134
# Before attempting to create the cluster AW, let's evaluate the ClusterConfig
155-
if self.config.dispatch_priority:
156-
if not self.config.appwrapper:
157-
raise ValueError(
158-
"Invalid Cluster Configuration, cannot have dispatch priority without MCAD"
159-
)
160-
priority_val = self.evaluate_dispatch_priority()
161-
if priority_val == None:
162-
raise ValueError(
163-
"Invalid Cluster Configuration, AppWrapper not generated"
164-
)
165-
else:
166-
priority_val = None
167135

168136
name = self.config.name
169137
namespace = self.config.namespace
@@ -183,7 +151,6 @@ def create_app_wrapper(self):
183151
instance_types = self.config.machine_types
184152
env = self.config.envs
185153
image_pull_secrets = self.config.image_pull_secrets
186-
dispatch_priority = self.config.dispatch_priority
187154
write_to_file = self.config.write_to_file
188155
verify_tls = self.config.verify_tls
189156
local_queue = self.config.local_queue
@@ -207,8 +174,6 @@ def create_app_wrapper(self):
207174
instance_types=instance_types,
208175
env=env,
209176
image_pull_secrets=image_pull_secrets,
210-
dispatch_priority=dispatch_priority,
211-
priority_val=priority_val,
212177
write_to_file=write_to_file,
213178
verify_tls=verify_tls,
214179
local_queue=local_queue,

src/codeflare_sdk/cluster/config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ class ClusterConfiguration:
5151
envs: dict = field(default_factory=dict)
5252
image: str = ""
5353
image_pull_secrets: list = field(default_factory=list)
54-
dispatch_priority: str = None
5554
write_to_file: bool = False
5655
verify_tls: bool = True
5756
labels: dict = field(default_factory=dict)

src/codeflare_sdk/utils/generate_yaml.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -103,21 +103,9 @@ def update_labels(yaml, instascale, instance_types):
103103
metadata.pop("labels")
104104

105105

106-
def update_priority(yaml, item, dispatch_priority, priority_val):
106+
def update_priority(yaml, item):
107107
spec = yaml.get("spec")
108-
if dispatch_priority is not None:
109-
if priority_val:
110-
spec["priority"] = priority_val
111-
else:
112-
raise ValueError(
113-
"AW generation error: Priority value is None, while dispatch_priority is defined"
114-
)
115-
head = item.get("generictemplate").get("spec").get("headGroupSpec")
116-
worker = item.get("generictemplate").get("spec").get("workerGroupSpecs")[0]
117-
head["template"]["spec"]["priorityClassName"] = dispatch_priority
118-
worker["template"]["spec"]["priorityClassName"] = dispatch_priority
119-
else:
120-
spec.pop("priority")
108+
spec.pop("priority")
121109

122110

123111
def update_custompodresources(
@@ -402,8 +390,6 @@ def generate_appwrapper(
402390
instance_types: list,
403391
env,
404392
image_pull_secrets: list,
405-
dispatch_priority: str,
406-
priority_val: int,
407393
write_to_file: bool,
408394
verify_tls: bool,
409395
local_queue: Optional[str],
@@ -421,7 +407,7 @@ def generate_appwrapper(
421407
namespace,
422408
)
423409
update_labels(user_yaml, instascale, instance_types)
424-
update_priority(user_yaml, item, dispatch_priority, priority_val)
410+
update_priority(user_yaml, item)
425411
update_custompodresources(
426412
item,
427413
min_cpu,

tests/test-case-prio.yaml

Lines changed: 0 additions & 205 deletions
This file was deleted.

tests/unit_test.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ def test_config_creation():
255255
assert config.instascale
256256
assert config.machine_types == ["cpu.small", "gpu.large"]
257257
assert config.image_pull_secrets == ["unit-test-pull-secret"]
258-
assert config.dispatch_priority == None
259258
assert config.appwrapper == True
260259

261260

@@ -387,30 +386,6 @@ def test_cluster_creation_no_mcad_local_queue(mocker):
387386
)
388387

389388

390-
def test_cluster_creation_priority(mocker):
391-
mocker.patch("kubernetes.client.ApisApi.get_api_versions")
392-
mocker.patch("kubernetes.config.load_kube_config", return_value="ignore")
393-
mocker.patch(
394-
"kubernetes.client.CustomObjectsApi.list_cluster_custom_object",
395-
return_value={"items": [{"metadata": {"name": "default"}, "value": 10}]},
396-
)
397-
config = createClusterConfig()
398-
config.name = "prio-test-cluster"
399-
config.dispatch_priority = "default"
400-
mocker.patch(
401-
"kubernetes.client.CustomObjectsApi.get_cluster_custom_object",
402-
return_value={"spec": {"domain": "apps.cluster.awsroute.org"}},
403-
)
404-
cluster = Cluster(config)
405-
assert cluster.app_wrapper_yaml == f"{aw_dir}prio-test-cluster.yaml"
406-
assert cluster.app_wrapper_name == "prio-test-cluster"
407-
assert filecmp.cmp(
408-
f"{aw_dir}prio-test-cluster.yaml",
409-
f"{parent}/tests/test-case-prio.yaml",
410-
shallow=True,
411-
)
412-
413-
414389
def test_default_cluster_creation(mocker):
415390
mocker.patch("kubernetes.client.ApisApi.get_api_versions")
416391
mocker.patch(
@@ -3194,7 +3169,6 @@ def test_rjc_list_jobs(ray_job_client, mocker):
31943169
# Make sure to always keep this function last
31953170
def test_cleanup():
31963171
os.remove(f"{aw_dir}unit-test-cluster.yaml")
3197-
os.remove(f"{aw_dir}prio-test-cluster.yaml")
31983172
os.remove(f"{aw_dir}test.yaml")
31993173
os.remove(f"{aw_dir}raytest2.yaml")
32003174
os.remove(f"{aw_dir}unit-test-cluster-ray.yaml")

0 commit comments

Comments
 (0)