Skip to content

Commit 6d39d04

Browse files
aslonnieclaude
andcommitted
[Release] Rename save_last_job_result to save_last_job_status
Rename method and parameter to better reflect the new JobStatus type. Add a warning log when the returned job ID doesn't match the expected one. Update FakeJobResult to FakeJobStatus in tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f62b7b0 commit 6d39d04

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

release/ray_release/job_manager/anyscale_job_manager.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,12 @@ def _run_job(
9696
logger.info(f"Link to job: " f"{format_link(self.job_url())}")
9797
return
9898

99-
def save_last_job_result(self, value):
100-
self._last_job_result = value
99+
def save_last_job_status(self, status):
100+
if status and hasattr(status, "id") and status.id != self._job_id:
101+
logger.warning(
102+
f"Job ID mismatch: expected {self._job_id}, got {status.id}"
103+
)
104+
self._last_job_result = status
101105

102106
def job_id(self) -> Optional[str]:
103107
return self._job_id
@@ -198,7 +202,7 @@ def _wait_job(self, timeout: int):
198202
next_status += 30
199203

200204
result = self._get_job_status_with_retry()
201-
self.save_last_job_result(result)
205+
self.save_last_job_status(result)
202206
status = self._last_job_status()
203207

204208
if not job_running and status in {
@@ -219,7 +223,7 @@ def _wait_job(self, timeout: int):
219223
time.sleep(1)
220224

221225
result = self._get_job_status_with_retry()
222-
self.save_last_job_result(result)
226+
self.save_last_job_status(result)
223227
status = self._last_job_status()
224228
assert status in terminal_state
225229
if status == JobState.FAILED and not job_running:

release/ray_release/tests/test_anyscale_job_manager.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22

33
import pytest
44

5+
from anyscale.job.models import JobState
6+
57
from ray_release.anyscale_util import Anyscale
68
from ray_release.cluster_manager.cluster_manager import ClusterManager
79
from ray_release.job_manager.anyscale_job_manager import AnyscaleJobManager
810
from ray_release.test import Test
911

1012

11-
class FakeJobResult:
12-
def __init__(self, _id: str):
13-
self.id = _id
13+
class FakeJobStatus:
14+
def __init__(self, state: JobState):
15+
self.state = state
1416

1517

1618
class FakeSDK(Anyscale):
@@ -32,6 +34,7 @@ def test_get_last_logs_long_running_job():
3234
anyscale_job_manager = AnyscaleJobManager(cluster_manager=cluster_manager)
3335
anyscale_job_manager._duration = 4 * 3_600 + 1
3436
anyscale_job_manager._job_id = "foo"
37+
anyscale_job_manager.save_last_job_status(FakeJobStatus(state=JobState.SUCCEEDED))
3538
assert anyscale_job_manager.get_last_logs() is None
3639

3740

0 commit comments

Comments
 (0)