Skip to content

Merge release-v171 into main#975

Open
podkidyshev wants to merge 2 commits into
mainfrom
release-v171
Open

Merge release-v171 into main#975
podkidyshev wants to merge 2 commits into
mainfrom
release-v171

Conversation

@podkidyshev

Copy link
Copy Markdown
Contributor

Summary

Upstream release v1.7.1 changes into main

Test Plan

  • Automated CI

Additional Notes

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Slurm job lifecycle

Layer / File(s) Summary
Runner tracking and shutdown cleanup
src/cloudai/systems/slurm/single_sbatch_runner.py
SingleSbatchRunner.run() tracks submitted jobs, kills jobs detected during shutdown, and always removes jobs from tracking.
Shutdown and completion coverage
tests/test_single_sbatch_runner.py
Tests cover shutdown during monitoring or submission, plus completed jobs that should not be killed.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: jeffnvidia

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title accurately states that release-v171 is being merged into main.
Description check ✅ Passed The description is clearly related to the merge and release v1.7.1 changes.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch release-v171

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/cloudai/systems/slurm/single_sbatch_runner.py`:
- Around line 190-193: Update the job submission flow around _submit_test so
placeholder jobs returned in dry-run mode are neither appended to tracking nor
passed to SlurmSystem.kill(); gate both operations on self.mode == "run". Add a
regression test covering shutdown during dry-run and verify no cancellation is
issued for the placeholder job.
- Around line 192-203: Move the self.shutting_down check and
self.system.kill(job) call inside the try/finally scope in the job monitoring
flow, preserving the existing loop behavior. Ensure self.jobs.remove(job) always
executes, including when killing the job raises.

In `@tests/test_single_sbatch_runner.py`:
- Around line 534-555: Extend the shutdown regression coverage around
test_run_tracks_and_cancels_job_on_shutdown with a cancellation-failure case
where SlurmSystem.kill raises, asserting runner.jobs is still cleared, and a
dry-run case asserting shutdown does not invoke Slurm cancellation. Reuse the
existing runner/job setup and monitoring shutdown flow, varying only the mode
and kill behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: d3a4d7e5-0f13-432d-8a55-7ac8810ba561

📥 Commits

Reviewing files that changed from the base of the PR and between 09f728c and f597e38.

📒 Files selected for processing (2)
  • src/cloudai/systems/slurm/single_sbatch_runner.py
  • tests/test_single_sbatch_runner.py

Comment on lines +190 to +193
self.jobs.append(job)

if self.shutting_down:
self.system.kill(job)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Do not cancel placeholder jobs in dry-run mode.

Dry-run _submit_test returns a SlurmJob with ID 0; this unconditional call reaches SlurmSystem.kill() and invokes scancel(0). Gate tracking and cancellation on self.mode == "run", and add a dry-run shutdown regression test.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/cloudai/systems/slurm/single_sbatch_runner.py` around lines 190 - 193,
Update the job submission flow around _submit_test so placeholder jobs returned
in dry-run mode are neither appended to tracking nor passed to
SlurmSystem.kill(); gate both operations on self.mode == "run". Add a regression
test covering shutdown during dry-run and verify no cancellation is issued for
the placeholder job.

Comment on lines +192 to +203
if self.shutting_down:
self.system.kill(job)

is_completed = False
while not is_completed:
if self.shutting_down:
break
is_completed = True if self.mode == "dry-run" else self.system.is_job_completed(job)
time.sleep(self.system.monitor_interval)
try:
while not is_completed:
if self.shutting_down:
break
is_completed = True if self.mode == "dry-run" else self.system.is_job_completed(job)
time.sleep(self.system.monitor_interval)
finally:
self.jobs.remove(job)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Keep cancellation inside the cleanup-protected scope.

If self.system.kill(job) raises, it executes before the try/finally, leaving job in self.jobs. Move the shutdown check into the try block so tracking is removed even when scancel fails.

Proposed fix
-        if self.shutting_down:
-            self.system.kill(job)
-
-        is_completed = False
         try:
+            if self.shutting_down:
+                self.system.kill(job)
+            is_completed = False
             while not is_completed:
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if self.shutting_down:
self.system.kill(job)
is_completed = False
while not is_completed:
if self.shutting_down:
break
is_completed = True if self.mode == "dry-run" else self.system.is_job_completed(job)
time.sleep(self.system.monitor_interval)
try:
while not is_completed:
if self.shutting_down:
break
is_completed = True if self.mode == "dry-run" else self.system.is_job_completed(job)
time.sleep(self.system.monitor_interval)
finally:
self.jobs.remove(job)
try:
if self.shutting_down:
self.system.kill(job)
is_completed = False
while not is_completed:
if self.shutting_down:
break
is_completed = True if self.mode == "dry-run" else self.system.is_job_completed(job)
time.sleep(self.system.monitor_interval)
finally:
self.jobs.remove(job)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/cloudai/systems/slurm/single_sbatch_runner.py` around lines 192 - 203,
Move the self.shutting_down check and self.system.kill(job) call inside the
try/finally scope in the job monitoring flow, preserving the existing loop
behavior. Ensure self.jobs.remove(job) always executes, including when killing
the job raises.

Comment on lines +534 to +555
def test_run_tracks_and_cancels_job_on_shutdown(sleep_tr: TestRun, slurm_system: SlurmSystem) -> None:
tc = TestScenario(name="tc", test_runs=[sleep_tr])
runner = SingleSbatchRunner(mode="run", system=slurm_system, test_scenario=tc, output_path=slurm_system.output_path)
job = SlurmJob(sleep_tr, id=123)
runner._submit_test = Mock(return_value=job)
runner.handle_dse = Mock()
runner.on_job_completion = Mock()

def shutdown_during_monitoring(monitored_job: SlurmJob) -> bool:
assert monitored_job is job
assert runner.jobs == [job]
runner.shutdown()
return False

with (
patch.object(SlurmSystem, "is_job_completed", side_effect=shutdown_during_monitoring),
patch.object(SlurmSystem, "kill") as kill,
):
runner.run()

kill.assert_called_once_with(job)
assert runner.jobs == []

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Add regression coverage for cancellation failures and dry-run shutdown.

These tests cover successful mode="run" cancellation only. Add cases asserting that a raised kill() still clears runner.jobs, and that shutdown in mode="dry-run" does not call Slurm cancellation.

Also applies to: 558-576, 578-594

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_single_sbatch_runner.py` around lines 534 - 555, Extend the
shutdown regression coverage around test_run_tracks_and_cancels_job_on_shutdown
with a cancellation-failure case where SlurmSystem.kill raises, asserting
runner.jobs is still cleared, and a dry-run case asserting shutdown does not
invoke Slurm cancellation. Reuse the existing runner/job setup and monitoring
shutdown flow, varying only the mode and kill behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant