Skip to content

Commit 547ddd7

Browse files
committed
remove dispatch_priority (not supported by v1beta2 AppWrapper)
1 parent 9e7851b commit 547ddd7

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
@@ -206,8 +173,6 @@ def create_app_wrapper(self):
206173
instance_types=instance_types,
207174
env=env,
208175
image_pull_secrets=image_pull_secrets,
209-
dispatch_priority=dispatch_priority,
210-
priority_val=priority_val,
211176
write_to_file=write_to_file,
212177
verify_tls=verify_tls,
213178
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

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(
@@ -390,8 +378,6 @@ def generate_appwrapper(
390378
instance_types: list,
391379
env,
392380
image_pull_secrets: list,
393-
dispatch_priority: str,
394-
priority_val: int,
395381
write_to_file: bool,
396382
verify_tls: bool,
397383
local_queue: Optional[str],
@@ -408,7 +394,7 @@ def generate_appwrapper(
408394
namespace,
409395
)
410396
update_labels(user_yaml, instascale, instance_types)
411-
update_priority(user_yaml, item, dispatch_priority, priority_val)
397+
update_priority(user_yaml, item)
412398
update_custompodresources(
413399
item,
414400
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

@@ -384,30 +383,6 @@ def test_cluster_creation_no_mcad_local_queue(mocker):
384383
)
385384

386385

387-
def test_cluster_creation_priority(mocker):
388-
mocker.patch("kubernetes.client.ApisApi.get_api_versions")
389-
mocker.patch("kubernetes.config.load_kube_config", return_value="ignore")
390-
mocker.patch(
391-
"kubernetes.client.CustomObjectsApi.list_cluster_custom_object",
392-
return_value={"items": [{"metadata": {"name": "default"}, "value": 10}]},
393-
)
394-
config = createClusterConfig()
395-
config.name = "prio-test-cluster"
396-
config.dispatch_priority = "default"
397-
mocker.patch(
398-
"kubernetes.client.CustomObjectsApi.get_cluster_custom_object",
399-
return_value={"spec": {"domain": "apps.cluster.awsroute.org"}},
400-
)
401-
cluster = Cluster(config)
402-
assert cluster.app_wrapper_yaml == f"{aw_dir}prio-test-cluster.yaml"
403-
assert cluster.app_wrapper_name == "prio-test-cluster"
404-
assert filecmp.cmp(
405-
f"{aw_dir}prio-test-cluster.yaml",
406-
f"{parent}/tests/test-case-prio.yaml",
407-
shallow=True,
408-
)
409-
410-
411386
def test_default_cluster_creation(mocker):
412387
mocker.patch("kubernetes.client.ApisApi.get_api_versions")
413388
mocker.patch(
@@ -3191,7 +3166,6 @@ def test_rjc_list_jobs(ray_job_client, mocker):
31913166
# Make sure to always keep this function last
31923167
def test_cleanup():
31933168
os.remove(f"{aw_dir}unit-test-cluster.yaml")
3194-
os.remove(f"{aw_dir}prio-test-cluster.yaml")
31953169
os.remove(f"{aw_dir}test.yaml")
31963170
os.remove(f"{aw_dir}raytest2.yaml")
31973171
os.remove(f"{aw_dir}unit-test-cluster-ray.yaml")

0 commit comments

Comments
 (0)