Skip to content

Commit 5a77f7b

Browse files
feat(RHOAIENG-26482): disable usage stats and rename RayJobClusterConfig
1 parent eac8cef commit 5a77f7b

File tree

8 files changed

+126
-58
lines changed

8 files changed

+126
-58
lines changed

codecov.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
coverage:
2+
precision: 2
3+
round: down
4+
status:
5+
project:
6+
default:
7+
target: auto
8+
threshold: 2.5%
9+
patch:
10+
default:
11+
target: 85%
12+
threshold: 2.5%
13+
14+
ignore:
15+
- "**/__init__.py"

src/codeflare_sdk/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
AppWrapperStatus,
1212
RayJobClient,
1313
RayJob,
14-
RayJobClusterConfig,
14+
ManagedClusterConfig,
1515
)
1616

1717
from .common.widgets import view_clusters

src/codeflare_sdk/ray/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from .rayjobs import (
88
RayJob,
9-
RayJobClusterConfig,
9+
ManagedClusterConfig,
1010
RayJobDeploymentStatus,
1111
CodeflareRayJobStatus,
1212
RayJobInfo,
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
from .rayjob import RayJob, RayJobClusterConfig
1+
from .rayjob import RayJob, ManagedClusterConfig
22
from .status import RayJobDeploymentStatus, CodeflareRayJobStatus, RayJobInfo
3-
from .config import RayJobClusterConfig
3+
from .config import ManagedClusterConfig

src/codeflare_sdk/ray/rayjobs/config.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
"""
16-
The config sub-module contains the definition of the RayJobClusterConfig dataclass,
16+
The config sub-module contains the definition of the ManagedClusterConfig dataclass,
1717
which is used to specify resource requirements and other details when creating a
1818
Cluster object.
1919
"""
@@ -104,7 +104,7 @@
104104

105105

106106
@dataclass
107-
class RayJobClusterConfig:
107+
class ManagedClusterConfig:
108108
"""
109109
This dataclass is used to specify resource requirements and other details for RayJobs.
110110
The cluster name and namespace are automatically derived from the RayJob configuration.
@@ -179,6 +179,8 @@ class RayJobClusterConfig:
179179
external_storage_namespace: Optional[str] = None
180180

181181
def __post_init__(self):
182+
self.envs["RAY_USAGE_STATS_ENABLED"] = "0"
183+
182184
if self.enable_gcs_ft:
183185
if not self.redis_address:
184186
raise ValueError(
@@ -223,7 +225,7 @@ def _memory_to_string(self):
223225
self.worker_memory_limits = f"{self.worker_memory_limits}G"
224226

225227
def _validate_types(self):
226-
"""Validate the types of all fields in the RayJobClusterConfig dataclass."""
228+
"""Validate the types of all fields in the ManagedClusterConfig dataclass."""
227229
errors = []
228230
for field_info in fields(self):
229231
value = getattr(self, field_info.name)
@@ -268,10 +270,10 @@ def check_type(value, expected_type):
268270

269271
def build_ray_cluster_spec(self, cluster_name: str) -> Dict[str, Any]:
270272
"""
271-
Build the RayCluster spec from RayJobClusterConfig for embedding in RayJob.
273+
Build the RayCluster spec from ManagedClusterConfig for embedding in RayJob.
272274
273275
Args:
274-
self: The cluster configuration object (RayJobClusterConfig)
276+
self: The cluster configuration object (ManagedClusterConfig)
275277
cluster_name: The name for the cluster (derived from RayJob name)
276278
277279
Returns:

src/codeflare_sdk/ray/rayjobs/rayjob.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from typing import Dict, Any, Optional, Tuple
2121
from python_client.kuberay_job_api import RayjobApi
2222

23-
from codeflare_sdk.ray.rayjobs.config import RayJobClusterConfig
23+
from codeflare_sdk.ray.rayjobs.config import ManagedClusterConfig
2424

2525
from ...common.utils import get_current_namespace
2626

@@ -48,7 +48,7 @@ def __init__(
4848
job_name: str,
4949
entrypoint: str,
5050
cluster_name: Optional[str] = None,
51-
cluster_config: Optional[RayJobClusterConfig] = None,
51+
cluster_config: Optional[ManagedClusterConfig] = None,
5252
namespace: Optional[str] = None,
5353
runtime_env: Optional[Dict[str, Any]] = None,
5454
shutdown_after_job_finishes: Optional[bool] = None,

src/codeflare_sdk/ray/rayjobs/test_config.py

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
"""
2-
Tests for the simplified RayJobClusterConfig accelerator_configs behavior.
2+
Tests for the simplified ManagedClusterConfig accelerator_configs behavior.
33
"""
44

55
import pytest
6-
from codeflare_sdk.ray.rayjobs.config import RayJobClusterConfig, DEFAULT_ACCELERATORS
6+
from codeflare_sdk.ray.rayjobs.config import ManagedClusterConfig, DEFAULT_ACCELERATORS
77

88

99
def test_accelerator_configs_defaults_to_default_accelerators():
1010
"""Test that accelerator_configs defaults to DEFAULT_ACCELERATORS.copy()"""
11-
config = RayJobClusterConfig()
11+
config = ManagedClusterConfig()
1212

1313
# Should have all the default accelerators
1414
assert "nvidia.com/gpu" in config.accelerator_configs
@@ -27,7 +27,7 @@ def test_accelerator_configs_can_be_overridden():
2727
"custom.com/accelerator": "CUSTOM_ACCELERATOR",
2828
}
2929

30-
config = RayJobClusterConfig(accelerator_configs=custom_configs)
30+
config = ManagedClusterConfig(accelerator_configs=custom_configs)
3131

3232
# Should have custom configs
3333
assert config.accelerator_configs == custom_configs
@@ -46,7 +46,7 @@ def test_accelerator_configs_can_extend_defaults():
4646
"custom.com/accelerator": "CUSTOM_ACCEL",
4747
}
4848

49-
config = RayJobClusterConfig(accelerator_configs=extended_configs)
49+
config = ManagedClusterConfig(accelerator_configs=extended_configs)
5050

5151
# Should have all defaults plus custom
5252
assert "nvidia.com/gpu" in config.accelerator_configs
@@ -57,15 +57,15 @@ def test_accelerator_configs_can_extend_defaults():
5757

5858
def test_gpu_validation_works_with_defaults():
5959
"""Test that GPU validation works with default accelerator configs"""
60-
config = RayJobClusterConfig(head_accelerators={"nvidia.com/gpu": 1})
60+
config = ManagedClusterConfig(head_accelerators={"nvidia.com/gpu": 1})
6161

6262
# Should not raise any errors
6363
assert config.head_accelerators == {"nvidia.com/gpu": 1}
6464

6565

6666
def test_gpu_validation_works_with_custom_configs():
6767
"""Test that GPU validation works with custom accelerator configs"""
68-
config = RayJobClusterConfig(
68+
config = ManagedClusterConfig(
6969
accelerator_configs={"custom.com/accelerator": "CUSTOM_ACCEL"},
7070
head_accelerators={"custom.com/accelerator": 1},
7171
)
@@ -79,4 +79,55 @@ def test_gpu_validation_fails_with_unsupported_accelerator():
7979
with pytest.raises(
8080
ValueError, match="GPU configuration 'unsupported.com/accelerator' not found"
8181
):
82-
RayJobClusterConfig(head_accelerators={"unsupported.com/accelerator": 1})
82+
ManagedClusterConfig(head_accelerators={"unsupported.com/accelerator": 1})
83+
84+
85+
def test_ray_usage_stats_always_disabled_by_default():
86+
"""Test that RAY_USAGE_STATS_ENABLED is always set to '0' by default"""
87+
config = ManagedClusterConfig()
88+
89+
# Should always have the environment variable set to "0"
90+
assert "RAY_USAGE_STATS_ENABLED" in config.envs
91+
assert config.envs["RAY_USAGE_STATS_ENABLED"] == "0"
92+
93+
94+
def test_ray_usage_stats_overwrites_user_env():
95+
"""Test that RAY_USAGE_STATS_ENABLED is always set to '0' even if user specifies it"""
96+
# User tries to enable usage stats
97+
config = ManagedClusterConfig(envs={"RAY_USAGE_STATS_ENABLED": "1"})
98+
99+
# Should still be disabled (our setting takes precedence)
100+
assert "RAY_USAGE_STATS_ENABLED" in config.envs
101+
assert config.envs["RAY_USAGE_STATS_ENABLED"] == "0"
102+
103+
104+
def test_ray_usage_stats_overwrites_user_env_string():
105+
"""Test that RAY_USAGE_STATS_ENABLED is always set to '0' even if user specifies it as string"""
106+
# User tries to enable usage stats with string
107+
config = ManagedClusterConfig(envs={"RAY_USAGE_STATS_ENABLED": "true"})
108+
109+
# Should still be disabled (our setting takes precedence)
110+
assert "RAY_USAGE_STATS_ENABLED" in config.envs
111+
assert config.envs["RAY_USAGE_STATS_ENABLED"] == "0"
112+
113+
114+
def test_ray_usage_stats_with_other_user_envs():
115+
"""Test that RAY_USAGE_STATS_ENABLED is set correctly while preserving other user envs"""
116+
# User sets other environment variables
117+
user_envs = {
118+
"CUSTOM_VAR": "custom_value",
119+
"ANOTHER_VAR": "another_value",
120+
"RAY_USAGE_STATS_ENABLED": "1", # This should be overwritten
121+
}
122+
123+
config = ManagedClusterConfig(envs=user_envs)
124+
125+
# Our setting should take precedence
126+
assert config.envs["RAY_USAGE_STATS_ENABLED"] == "0"
127+
128+
# Other user envs should be preserved
129+
assert config.envs["CUSTOM_VAR"] == "custom_value"
130+
assert config.envs["ANOTHER_VAR"] == "another_value"
131+
132+
# Total count should be correct (3 user envs)
133+
assert len(config.envs) == 3

0 commit comments

Comments
 (0)