Skip to content

Commit 5b4999d

Browse files
committed
Fixed failing unit tests
Signed-off-by: Pat O'Connor <[email protected]>
1 parent b3251fc commit 5b4999d

File tree

9 files changed

+75
-228
lines changed

9 files changed

+75
-228
lines changed

src/codeflare_sdk/ray/cluster/cluster.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from time import sleep
2222
from typing import List, Optional, Tuple, Dict
2323
import copy
24+
import dataclasses
2425

2526
from ray.job_submission import JobSubmissionClient, JobStatus
2627
import time
@@ -1059,10 +1060,13 @@ def get_cluster(
10591060
)
10601061
# 1. Prepare RayClusterSpec from ClusterConfiguration
10611062
# Create a temporary config with appwrapper=False to ensure build_ray_cluster returns RayCluster YAML
1062-
temp_cluster_config_dict = cluster_config.dict(
1063-
exclude_none=True
1064-
) # Assuming Pydantic V1 or similar .dict() method
1063+
temp_cluster_config_dict = dataclasses.asdict(cluster_config)
1064+
# Filter out None values similar to exclude_none=True in Pydantic
1065+
temp_cluster_config_dict = {k: v for k, v in temp_cluster_config_dict.items() if v is not None}
10651066
temp_cluster_config_dict["appwrapper"] = False
1067+
# Set overwrite_default_resource_mapping=True to avoid conflicts when extended_resource_mapping
1068+
# already contains the combined default and custom mappings from the original object
1069+
temp_cluster_config_dict["overwrite_default_resource_mapping"] = True
10661070
temp_cluster_config_for_spec = ClusterConfiguration(**temp_cluster_config_dict)
10671071
# Ignore the warning here for the lack of a ClusterConfiguration
10681072
with warnings.catch_warnings():

src/codeflare_sdk/ray/rayjobs/test_rayjob.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ def test_rayjob_submit_success(mocker):
2626
mock_api_instance = MagicMock()
2727
mock_api_class.return_value = mock_api_instance
2828

29-
# Configure the mock to return success when submit is called
30-
mock_api_instance.submit.return_value = {"metadata": {"name": "test-rayjob"}}
29+
# Configure the mock to return success when submit_job is called
30+
mock_api_instance.submit_job.return_value = {"metadata": {"name": "test-rayjob"}}
3131

3232
# Create RayJob instance
3333
rayjob = RayJob(
@@ -45,8 +45,8 @@ def test_rayjob_submit_success(mocker):
4545
assert job_id == "test-rayjob"
4646

4747
# Verify the API was called with correct parameters
48-
mock_api_instance.submit.assert_called_once()
49-
call_args = mock_api_instance.submit.call_args
48+
mock_api_instance.submit_job.assert_called_once()
49+
call_args = mock_api_instance.submit_job.call_args
5050

5151
# Check the namespace parameter
5252
assert call_args.kwargs["k8s_namespace"] == "test-namespace"

test.ipynb

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

tests/test_cluster_yamls/appwrapper/unit-test-all-params.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ spec:
1919
controller-tools.k8s.io: '1.0'
2020
key1: value1
2121
key2: value2
22+
ray.io/cluster: aw-all-params
2223
name: aw-all-params
2324
namespace: ns
2425
spec:
@@ -38,6 +39,7 @@ spec:
3839
rayStartParams:
3940
block: 'true'
4041
dashboard-host: 0.0.0.0
42+
dashboard-port: '8265'
4143
num-gpus: '1'
4244
resources: '"{\"TPU\": 2}"'
4345
serviceType: ClusterIP

tests/test_cluster_yamls/kueue/aw_kueue.yaml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ spec:
1212
kind: RayCluster
1313
metadata:
1414
labels:
15-
controller-tools.k8s.io: '1.0'
15+
controller-tools.k8s.io: "1.0"
16+
ray.io/cluster: unit-test-aw-kueue
1617
name: unit-test-aw-kueue
1718
namespace: ns
1819
spec:
@@ -30,15 +31,19 @@ spec:
3031
headGroupSpec:
3132
enableIngress: false
3233
rayStartParams:
33-
block: 'true'
34+
block: "true"
3435
dashboard-host: 0.0.0.0
35-
num-gpus: '0'
36+
dashboard-port: "8265"
37+
num-gpus: "0"
3638
resources: '"{}"'
3739
serviceType: ClusterIP
3840
template:
3941
spec:
4042
containers:
41-
- image: "${image}"
43+
- env:
44+
- name: RAY_USAGE_STATS_ENABLED
45+
value: "0"
46+
image: quay.io/modh/ray@sha256:6d076aeb38ab3c34a6a2ef0f58dc667089aa15826fa08a73273c629333e12f1e
4247
imagePullPolicy: Always
4348
lifecycle:
4449
preStop:
@@ -75,9 +80,6 @@ spec:
7580
- mountPath: /etc/ssl/certs/odh-ca-bundle.crt
7681
name: odh-ca-cert
7782
subPath: odh-ca-bundle.crt
78-
env:
79-
- name: RAY_USAGE_STATS_ENABLED
80-
value: '0'
8183
volumes:
8284
- configMap:
8385
items:
@@ -99,14 +101,17 @@ spec:
99101
maxReplicas: 2
100102
minReplicas: 2
101103
rayStartParams:
102-
block: 'true'
103-
num-gpus: '0'
104+
block: "true"
105+
num-gpus: "0"
104106
resources: '"{}"'
105107
replicas: 2
106108
template:
107109
spec:
108110
containers:
109-
- image: "${image}"
111+
- env:
112+
- name: RAY_USAGE_STATS_ENABLED
113+
value: "0"
114+
image: quay.io/modh/ray@sha256:6d076aeb38ab3c34a6a2ef0f58dc667089aa15826fa08a73273c629333e12f1e
110115
imagePullPolicy: Always
111116
lifecycle:
112117
preStop:
@@ -136,9 +141,6 @@ spec:
136141
- mountPath: /etc/ssl/certs/odh-ca-bundle.crt
137142
name: odh-ca-cert
138143
subPath: odh-ca-bundle.crt
139-
env:
140-
- name: RAY_USAGE_STATS_ENABLED
141-
value: '0'
142144
volumes:
143145
- configMap:
144146
items:

tests/test_cluster_yamls/kueue/ray_cluster_kueue.yaml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ spec:
1212
kind: RayCluster
1313
metadata:
1414
labels:
15-
controller-tools.k8s.io: '1.0'
15+
controller-tools.k8s.io: "1.0"
16+
ray.io/cluster: unit-test-cluster-kueue
1617
name: unit-test-cluster-kueue
1718
namespace: ns
1819
spec:
@@ -30,15 +31,19 @@ spec:
3031
headGroupSpec:
3132
enableIngress: false
3233
rayStartParams:
33-
block: 'true'
34+
block: "true"
3435
dashboard-host: 0.0.0.0
35-
num-gpus: '0'
36+
dashboard-port: "8265"
37+
num-gpus: "0"
3638
resources: '"{}"'
3739
serviceType: ClusterIP
3840
template:
3941
spec:
4042
containers:
41-
- image: "${image}"
43+
- env:
44+
- name: RAY_USAGE_STATS_ENABLED
45+
value: "0"
46+
image: quay.io/modh/ray@sha256:6d076aeb38ab3c34a6a2ef0f58dc667089aa15826fa08a73273c629333e12f1e
4247
imagePullPolicy: Always
4348
lifecycle:
4449
preStop:
@@ -75,9 +80,6 @@ spec:
7580
- mountPath: /etc/ssl/certs/odh-ca-bundle.crt
7681
name: odh-ca-cert
7782
subPath: odh-ca-bundle.crt
78-
env:
79-
- name: RAY_USAGE_STATS_ENABLED
80-
value: '0'
8183
volumes:
8284
- configMap:
8385
items:
@@ -99,14 +101,17 @@ spec:
99101
maxReplicas: 2
100102
minReplicas: 2
101103
rayStartParams:
102-
block: 'true'
103-
num-gpus: '0'
104+
block: "true"
105+
num-gpus: "0"
104106
resources: '"{}"'
105107
replicas: 2
106108
template:
107109
spec:
108110
containers:
109-
- image: "${image}"
111+
- env:
112+
- name: RAY_USAGE_STATS_ENABLED
113+
value: "0"
114+
image: quay.io/modh/ray@sha256:6d076aeb38ab3c34a6a2ef0f58dc667089aa15826fa08a73273c629333e12f1e
110115
imagePullPolicy: Always
111116
lifecycle:
112117
preStop:
@@ -136,9 +141,6 @@ spec:
136141
- mountPath: /etc/ssl/certs/odh-ca-bundle.crt
137142
name: odh-ca-cert
138143
subPath: odh-ca-bundle.crt
139-
env:
140-
- name: RAY_USAGE_STATS_ENABLED
141-
value: '0'
142144
volumes:
143145
- configMap:
144146
items:

0 commit comments

Comments
 (0)