Skip to content

Commit 26e0da9

Browse files
committed
chop custompod stanzas from appwrapper
1 parent f14dc93 commit 26e0da9

File tree

6 files changed

+3
-198
lines changed

6 files changed

+3
-198
lines changed

src/codeflare_sdk/templates/base-template.yaml

-20
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,6 @@ spec:
88
Items: []
99
GenericItems:
1010
- replicas: 1
11-
#new addition
12-
custompodresources:
13-
- replicas: 1
14-
requests:
15-
cpu: 2
16-
memory: 8G
17-
nvidia.com/gpu: 0
18-
limits:
19-
cpu: 2
20-
memory: 8G
21-
nvidia.com/gpu: 0
22-
- replicas: 3
23-
requests:
24-
cpu: 2
25-
memory: 12G
26-
nvidia.com/gpu: 1
27-
limits:
28-
cpu: 2
29-
memory: 12G
30-
nvidia.com/gpu: 1
3111
generictemplate:
3212
# This config demonstrates KubeRay's Ray autoscaler integration.
3313
# The resource requests and limits in this config are too small for production!

src/codeflare_sdk/utils/generate_yaml.py

-62
Original file line numberDiff line numberDiff line change
@@ -87,56 +87,6 @@ def update_names(yaml, item, appwrapper_name, cluster_name, namespace):
8787
lower_meta["namespace"] = namespace
8888

8989

90-
def update_custompodresources(
91-
item,
92-
min_cpu,
93-
max_cpu,
94-
min_memory,
95-
max_memory,
96-
gpu,
97-
workers,
98-
head_cpus,
99-
head_memory,
100-
head_gpus,
101-
):
102-
if "custompodresources" in item.keys():
103-
custompodresources = item.get("custompodresources")
104-
for i in range(len(custompodresources)):
105-
resource = custompodresources[i]
106-
if i == 0:
107-
# Leave head node resources as template default
108-
resource["requests"]["cpu"] = head_cpus
109-
resource["limits"]["cpu"] = head_cpus
110-
resource["requests"]["memory"] = head_memory
111-
resource["limits"]["memory"] = head_memory
112-
resource["requests"]["nvidia.com/gpu"] = head_gpus
113-
resource["limits"]["nvidia.com/gpu"] = head_gpus
114-
115-
else:
116-
for k, v in resource.items():
117-
if k == "replicas" and i == 1:
118-
resource[k] = workers
119-
if k == "requests" or k == "limits":
120-
for spec, _ in v.items():
121-
if spec == "cpu":
122-
if k == "limits":
123-
resource[k][spec] = max_cpu
124-
else:
125-
resource[k][spec] = min_cpu
126-
if spec == "memory":
127-
if k == "limits":
128-
resource[k][spec] = max_memory
129-
else:
130-
resource[k][spec] = min_memory
131-
if spec == "nvidia.com/gpu":
132-
if i == 0:
133-
resource[k][spec] = 0
134-
else:
135-
resource[k][spec] = gpu
136-
else:
137-
sys.exit("Error: malformed template")
138-
139-
14090
def update_image(spec, image):
14191
containers = spec.get("containers")
14292
for container in containers:
@@ -355,18 +305,6 @@ def generate_appwrapper(
355305
cluster_name,
356306
namespace,
357307
)
358-
update_custompodresources(
359-
item,
360-
min_cpu,
361-
max_cpu,
362-
min_memory,
363-
max_memory,
364-
gpu,
365-
workers,
366-
head_cpus,
367-
head_memory,
368-
head_gpus,
369-
)
370308
update_nodes(
371309
item,
372310
appwrapper_name,

tests/test-case-bad.yaml

+1-20
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,7 @@ metadata:
88
spec:
99
resources:
1010
GenericItems:
11-
- custompodresources:
12-
- limits:
13-
cpu: 2
14-
memory: 8G
15-
nvidia.com/gpu: 0
16-
replicas: 1
17-
requests:
18-
cpu: 2
19-
memory: 8G
20-
nvidia.com/gpu: 0
21-
- limits:
22-
cpu: 4
23-
memory: 6G
24-
nvidia.com/gpu: 7
25-
replicas: 2
26-
requests:
27-
cpu: 3
28-
memory: 5G
29-
nvidia.com/gpu: 7
30-
generictemplate:
11+
- generictemplate:
3112
apiVersion: ray.io/v1
3213
kind: RayCluster
3314
metadata:

tests/test-case.yaml

+1-20
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,7 @@ metadata:
66
spec:
77
resources:
88
GenericItems:
9-
- custompodresources:
10-
- limits:
11-
cpu: 2
12-
memory: 8G
13-
nvidia.com/gpu: 0
14-
replicas: 1
15-
requests:
16-
cpu: 2
17-
memory: 8G
18-
nvidia.com/gpu: 0
19-
- limits:
20-
cpu: 4
21-
memory: 6G
22-
nvidia.com/gpu: 7
23-
replicas: 2
24-
requests:
25-
cpu: 3
26-
memory: 5G
27-
nvidia.com/gpu: 7
28-
generictemplate:
9+
- generictemplate:
2910
apiVersion: ray.io/v1
3011
kind: RayCluster
3112
metadata:

tests/test-default-appwrapper.yaml

+1-20
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,7 @@ metadata:
66
spec:
77
resources:
88
GenericItems:
9-
- custompodresources:
10-
- limits:
11-
cpu: 2
12-
memory: 8G
13-
nvidia.com/gpu: 0
14-
replicas: 1
15-
requests:
16-
cpu: 2
17-
memory: 8G
18-
nvidia.com/gpu: 0
19-
- limits:
20-
cpu: 1
21-
memory: 2G
22-
nvidia.com/gpu: 0
23-
replicas: 1
24-
requests:
25-
cpu: 1
26-
memory: 2G
27-
nvidia.com/gpu: 0
28-
generictemplate:
9+
- generictemplate:
2910
apiVersion: ray.io/v1
3011
kind: RayCluster
3112
metadata:

tests/unit_test.py

-56
Original file line numberDiff line numberDiff line change
@@ -1547,34 +1547,6 @@ def get_aw_obj(group, version, namespace, plural):
15471547
"GenericItems": [
15481548
{
15491549
"allocated": 0,
1550-
"custompodresources": [
1551-
{
1552-
"limits": {
1553-
"cpu": "2",
1554-
"memory": "8G",
1555-
"nvidia.com/gpu": "0",
1556-
},
1557-
"replicas": 1,
1558-
"requests": {
1559-
"cpu": "2",
1560-
"memory": "8G",
1561-
"nvidia.com/gpu": "0",
1562-
},
1563-
},
1564-
{
1565-
"limits": {
1566-
"cpu": "1",
1567-
"memory": "2G",
1568-
"nvidia.com/gpu": "0",
1569-
},
1570-
"replicas": 1,
1571-
"requests": {
1572-
"cpu": "1",
1573-
"memory": "2G",
1574-
"nvidia.com/gpu": "0",
1575-
},
1576-
},
1577-
],
15781550
"generictemplate": {
15791551
"apiVersion": "ray.io/v1",
15801552
"kind": "RayCluster",
@@ -1816,34 +1788,6 @@ def get_aw_obj(group, version, namespace, plural):
18161788
"GenericItems": [
18171789
{
18181790
"allocated": 0,
1819-
"custompodresources": [
1820-
{
1821-
"limits": {
1822-
"cpu": "2",
1823-
"memory": "8G",
1824-
"nvidia.com/gpu": "0",
1825-
},
1826-
"replicas": 1,
1827-
"requests": {
1828-
"cpu": "2",
1829-
"memory": "8G",
1830-
"nvidia.com/gpu": "0",
1831-
},
1832-
},
1833-
{
1834-
"limits": {
1835-
"cpu": "1",
1836-
"memory": "2G",
1837-
"nvidia.com/gpu": "0",
1838-
},
1839-
"replicas": 1,
1840-
"requests": {
1841-
"cpu": "1",
1842-
"memory": "2G",
1843-
"nvidia.com/gpu": "0",
1844-
},
1845-
},
1846-
],
18471791
"generictemplate": {
18481792
"apiVersion": "ray.io/v1",
18491793
"kind": "RayCluster",

0 commit comments

Comments
 (0)