Skip to content

Commit d5038b6

Browse files
committed
fix
Signed-off-by: oliver könig <okoenig@nvidia.com>
1 parent 98faac1 commit d5038b6

File tree

1 file changed

+5
-58
lines changed

1 file changed

+5
-58
lines changed

test/run/ray/test_kuberay.py

Lines changed: 5 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -2195,75 +2195,22 @@ def test_kuberay_job_both_configs_fail(self):
21952195
assert exc_info.value == kube_error
21962196
assert "Kube config file not found" in str(exc_info.value)
21972197

2198-
def test_executor_kube_config_success(self):
2199-
"""Test KubeRayExecutor when kube config loads successfully."""
2200-
with patch(
2201-
"nemo_run.core.execution.kuberay.config.load_kube_config"
2202-
) as mock_load_kube:
2203-
with patch(
2204-
"nemo_run.core.execution.kuberay.config.load_incluster_config"
2205-
) as mock_incluster:
2206-
with patch("nemo_run.core.execution.kuberay.client.CustomObjectsApi"):
2207-
with patch("nemo_run.core.execution.kuberay.client.CoreV1Api"):
2208-
# Create executor to trigger __post_init__ which loads config
2209-
_ = KubeRayExecutor(namespace="test-namespace")
2210-
2211-
# Verify kube config was loaded and incluster was NOT called
2212-
mock_load_kube.assert_called_once()
2213-
mock_incluster.assert_not_called()
2214-
2215-
def test_executor_fallback_to_incluster(self):
2216-
"""Test KubeRayExecutor falls back to incluster config when kube config fails."""
2217-
kube_error = Exception("Kube config file not found")
2218-
2219-
with patch(
2220-
"nemo_run.core.execution.kuberay.config.load_kube_config", side_effect=kube_error
2221-
) as mock_load_kube:
2222-
with patch(
2223-
"nemo_run.core.execution.kuberay.config.load_incluster_config"
2224-
) as mock_incluster:
2225-
with patch("nemo_run.core.execution.kuberay.client.CustomObjectsApi"):
2226-
with patch("nemo_run.core.execution.kuberay.client.CoreV1Api"):
2227-
# Create executor to trigger __post_init__ which loads config
2228-
_ = KubeRayExecutor(namespace="test-namespace")
2229-
2230-
# Verify fallback occurred
2231-
mock_load_kube.assert_called_once()
2232-
mock_incluster.assert_called_once()
2233-
2234-
def test_executor_both_configs_fail(self):
2235-
"""Test KubeRayExecutor raises original error when both configs fail."""
2236-
kube_error = Exception("Kube config file not found")
2237-
incluster_error = Exception("Not running inside a cluster")
2238-
2239-
with patch(
2240-
"nemo_run.core.execution.kuberay.config.load_kube_config", side_effect=kube_error
2241-
):
2242-
with patch(
2243-
"nemo_run.core.execution.kuberay.config.load_incluster_config",
2244-
side_effect=incluster_error,
2245-
):
2246-
with pytest.raises(Exception) as exc_info:
2247-
KubeRayExecutor(namespace="test-namespace")
2248-
2249-
# Should raise the original kube config error (not the incluster error)
2250-
assert exc_info.value == kube_error
2251-
assert "Kube config file not found" in str(exc_info.value)
2252-
22532198
def test_error_chaining_preserved(self):
22542199
"""Test that error chaining is preserved (raise X from Y)."""
22552200
kube_error = Exception("Kube config file not found")
22562201
incluster_error = Exception("Not running inside a cluster")
22572202

22582203
with patch(
2259-
"nemo_run.core.execution.kuberay.config.load_kube_config", side_effect=kube_error
2204+
"nemo_run.run.ray.kuberay.config.load_kube_config", side_effect=kube_error
22602205
):
22612206
with patch(
2262-
"nemo_run.core.execution.kuberay.config.load_incluster_config",
2207+
"nemo_run.run.ray.kuberay.config.load_incluster_config",
22632208
side_effect=incluster_error,
22642209
):
22652210
with pytest.raises(Exception) as exc_info:
2266-
KubeRayExecutor(namespace="test-namespace")
2211+
with patch("nemo_run.run.ray.kuberay.get_user", return_value="testuser"):
2212+
executor = KubeRayExecutor(namespace="test-namespace")
2213+
KubeRayJob(name="test-job", executor=executor)
22672214

22682215
# Verify error chaining (raise kube_error from incluster_error)
22692216
assert exc_info.value == kube_error

0 commit comments

Comments
 (0)