Skip to content

fix(orchestration): reuse a venv under skip_venv_if_present only when setup completed - #5797

Merged
yfw merged 4 commits into
mainfrom
cmunley/venv-done-marker
Nov 12, 2026
Merged

yfw merged 4 commits into
mainfrom
cmunley/venv-done-marker

Conversation

@cmunley1

@cmunley1 cmunley1 commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

What broke

Cancelling a run during its venv install leaves bin/python and bin/activate without the packages. With skip_venv_if_present=true the next run reused that venv, because it only checked those two files, and the server died at spinup ("policy_model finished unexpectedly").

Fix

Reuse a venv only when it also has the .nemo-gym-setup-complete marker that venv_setup already writes after a successful install. Otherwise log a warning naming the venv and reinstall in place under the existing setup lock. No directory is deleted. Venvs without the marker, including ones built before it existed, reinstall once.

Test

test_server_venv.py: a venv without the marker rebuilds and warns, a venv with it skips (legacy and locked paths). tests/unit_tests/orchestration + cli/test_cli.py: 3395 passed. The 6 test_eval_resubmit.py failures also fail on main.

Compatibility

This reverses the #3551 behavior for prebuilt venvs without the marker. Such a venv is no longer reused. Gym reinstalls it under <venv>.setup.lock in its parent directory, which fails on a read-only mount (for example a squashfs image built before the marker landed on 2026-09-18) or on an offline cluster. To adopt a known-good venv, run touch <venv>/.nemo-gym-setup-complete, or rebuild the image. The warning prints this command, and AGENTS.md is updated.

… setup completed

Cancelling a run during its venv install leaves bin/python and bin/activate
without the packages. skip_venv_if_present reused such a venv because it only
checked those two files, and the server then died at spinup.

Reuse a venv only when it also has the completion marker that venv_setup
writes after a successful install. Otherwise log a warning naming the venv and
reinstall in place under the existing setup lock. Venvs without the marker,
including ones built before the marker existed, reinstall once.

Signed-off-by: Christian Munley <[email protected]>
@copy-pr-bot

copy-pr-bot Bot commented Nov 7, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@cmunley1
cmunley1 marked this pull request as ready for review November 7, 2026 05:48
@cmunley1

cmunley1 commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 03a14c9

@cmunley1

cmunley1 commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

/review

@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team November 7, 2026 05:49
@svcnvidia-nemo-ci svcnvidia-nemo-ci added the bug Something isn't working label Nov 7, 2026
@svcnvidia-nemo-ci svcnvidia-nemo-ci added the area:orchestration Job submission, deployment, services, and lifecycle management label Nov 7, 2026

@svcnvidia-nemo-ci svcnvidia-nemo-ci 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.

SHIP

LGTM — no concerns found. I checked both setup paths, the completion-marker and lock lifecycle, affected launch callers, and the regression tests. Markerless venvs now enter serialized setup, while complete venvs retain lock-free reuse.

Static review only; I didn't execute tests.

Note: formal approval is not available for this request, so this review is posted as a comment only.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added the needs-review PR is ready for code review and waiting on a reviewer label Nov 7, 2026
Resolve conflicts with main.

Signed-off-by: Christian Munley <[email protected]>
@cmunley1

Copy link
Copy Markdown
Contributor Author

/ok to test c3e1447

@cmunley1

Copy link
Copy Markdown
Contributor Author

/review

@svcnvidia-nemo-ci svcnvidia-nemo-ci 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.

SHIP

LGTM — no concerns found in this follow-up. I compared the changes since the prior clean review and checked the relocated setup helpers, launch integration, and regression tests.

The completion-marker fix is preserved: markerless venvs enter serialized setup, while complete venvs retain lock-free reuse. I found no introduced regression in the inspected paths.

Static review only; I didn’t execute tests.

Review generated by codex. This was a findings-only review. Request a full review with /review reset=true.

@yaoyu-33 yaoyu-33 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.

Reviewed at c3e1447. The marker-based check is right: venv_setup removes the marker before each install and writes it only after a successful one under the setup lock, so the lock-free reuse path can no longer pick up an interrupted install, and the updated tests would fail on main. One compatibility point is inline; with that called out this looks good to me.

yaoyu-33
yaoyu-33 previously approved these changes Nov 11, 2026

@yaoyu-33 yaoyu-33 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.

LGTM. The inline points from my earlier review are small and can be handled here or in a follow-up.

@yaoyu-33 yaoyu-33 added ready-to-merge PR is approved, current, and waiting for final CI or merge and removed needs-review PR is ready for code review and waiting on a reviewer labels Nov 11, 2026
@cmunley1
cmunley1 added this pull request to the merge queue Nov 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/43101281510

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 11, 2026
The warning now names the touch command for a known-good venv, and
AGENTS.md no longer says a bare .venv skips setup.

Signed-off-by: Christian Munley <[email protected]>
@cmunley1

Copy link
Copy Markdown
Contributor Author

/ok to test 5f785cc

@cmunley1
cmunley1 requested a review from yaoyu-33 November 11, 2026 21:42
@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team November 11, 2026 21:43
Signed-off-by: Christian Munley <[email protected]>
@cmunley1

Copy link
Copy Markdown
Contributor Author

/ok to test e4921b7

@yfw
yfw added this pull request to the merge queue Nov 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/43308806274

Merged via the queue into main with commit 9a3ad5a Nov 12, 2026
68 of 70 checks passed
@yfw
yfw deleted the cmunley/venv-done-marker branch November 12, 2026 21:31

This branch had an error being deployed

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

Labels

area:orchestration Job submission, deployment, services, and lifecycle management bug Something isn't working ready-to-merge PR is approved, current, and waiting for final CI or merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants