Skip to content

Commit ad10aef

Browse files
committed
prune mocked appwrappers
1 parent f14dc93 commit ad10aef

File tree

6 files changed

+3
-362
lines changed

6 files changed

+3
-362
lines changed

src/codeflare_sdk/templates/base-template.yaml

-21
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,8 @@ metadata:
55
namespace: default
66
spec:
77
resources:
8-
Items: []
98
GenericItems:
109
- 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
3110
generictemplate:
3211
# This config demonstrates KubeRay's Ray autoscaler integration.
3312
# 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-21
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:
@@ -179,4 +160,3 @@ spec:
179160
optional: true
180161
name: odh-ca-cert
181162
replicas: 1
182-
Items: []

tests/test-default-appwrapper.yaml

+1-21
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:
@@ -177,4 +158,3 @@ spec:
177158
optional: true
178159
name: odh-ca-cert
179160
replicas: 1
180-
Items: []

0 commit comments

Comments
 (0)