Skip to content

Route runtests.sh ruff invocations through PY_EXE - #9089

Open
hjmjohnson wants to merge 1 commit into
Project-MONAI:devfrom
BRAINSia:mono-runtests-ruff-pyexe
Open

Route runtests.sh ruff invocations through PY_EXE#9089
hjmjohnson wants to merge 1 commit into
Project-MONAI:devfrom
BRAINSia:mono-runtests-ruff-pyexe

Conversation

@hjmjohnson

Copy link
Copy Markdown
Contributor

runtests.sh calls every other formatter (black, isort, pylint, pytype) through "${PY_EXE}" -m; the ruff invocations still called a bare ruff off PATH. is_pip_installed ruff checks $PY_EXE, so the guard and the invocation could disagree — in a clean venv built per CONTRIBUTING.md with no editable PATH entry, ./runtests.sh --codeformat fails with ruff: command not found even though ruff is installed and importable from $PY_EXE.

No behavior change when ruff happens to already be on PATH (the common case in an activated venv); this only fixes the case where it isn't.

Reproduced before/after

With $PY_EXE pointed at a venv holding ruff, and that venv absent from PATH:

$ MONAI_PY_EXE=/path/to/venv/bin/python bash -c 'PY_EXE=$MONAI_PY_EXE; ruff --version'
bash: line 1: ruff: command not found

$ MONAI_PY_EXE=/path/to/venv/bin/python bash -c 'PY_EXE=$MONAI_PY_EXE; "${PY_EXE}" -m ruff --version'
ruff 0.16.5

./runtests.sh --ruff with $PY_EXE set and the venv not on PATH now reaches All checks passed! instead of failing at the version check.

@coderabbitai

coderabbitai Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: 191ac35d-b51e-49f1-b09c-333dd7e99e9f

📥 Commits

Reviewing files that changed from the base of the PR and between 9ea04d4 and 303842d.

📒 Files selected for processing (1)
  • runtests.sh

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

runtests.sh now runs the Ruff version check and both Ruff check variants through "${PY_EXE}" -m ruff. Existing fix, unsafe-fix, and file-exclusion options remain unchanged.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Merge Risk: ⚪ Minimal · up to 2da2a

Ruff now consistently runs through the configured Python interpreter, avoiding PATH-dependent failures while preserving existing check options. The change is ready to merge.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: routing runtests.sh Ruff invocations through PY_EXE.
Description check ✅ Passed The description clearly explains the PATH-related failure, the cause, the fix, the behavior impact, and a before/after reproduction. It provides sufficient context despite omitting the template checkl…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
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.
Full details: Description check

Explanation

The description clearly explains the PATH-related failure, the cause, the fix, the behavior impact, and a before/after reproduction. It provides sufficient context despite omitting the template checklist and issue reference.

Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

runtests.sh calls every other formatter (black, isort, pylint, pytype)
via "${PY_EXE}" -m so it targets the same interpreter the
is_pip_installed() guard checked. The ruff invocations still called a
bare `ruff` off PATH, so is_pip_installed("ruff") could pass against
$PY_EXE while the invocation ran a different (or absent) ruff from
PATH. In a clean venv built per CONTRIBUTING.md with no editable
PATH entry, ./runtests.sh --codeformat fails with
"ruff: command not found" even though ruff is installed and
importable from $PY_EXE.

Reproduced: with $PY_EXE pointed at a venv holding ruff and that
venv absent from PATH, the old `ruff --version` failed with
"command not found"; "${PY_EXE}" -m ruff --version succeeded.

Signed-off-by: Hans Johnson <hans-johnson@uiowa.edu>
@hjmjohnson
hjmjohnson force-pushed the mono-runtests-ruff-pyexe branch from 303842d to 2da2aed Compare September 3, 2026 15:12
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