Check Environment Script - #9038
Conversation
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe change adds a standalone environment diagnostic script with platform, package, PyTorch, CUDA, and MONAI checks. Configuration output now uses anonymized, flushed printing, and the deprecated Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
monai/config/check_env.py (1)
57-150: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winComplete the new utility docstrings.
monai/config/check_env.py#L57-L150: Document*argsand**kwargsforfprint. AddReturnssections for Boolean diagnostic checks.monai/config/deviceconfig.py#L54-L61: Document*args,**kwargs, and theNonereturn value forfprint.As per path instructions, “Docstrings should be present for all definition which describe each variable, return value, and raised exception in the appropriate section of the Google-style of docstrings.”
🤖 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 `@monai/config/check_env.py` around lines 57 - 150, Complete the Google-style docstrings for fprint, print_environment, check_torch, check_torch_cuda, and check_monai in monai/config/check_env.py: document fprint’s *args and **kwargs, and add Returns sections describing the Boolean diagnostic results for each check function. Also update fprint in monai/config/deviceconfig.py to document *args, **kwargs, and its None return value; make no other behavioral changes.Source: Path instructions
tests/config/test_print_info.py (1)
22-25: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick winTest the anonymization contract.
out.tell()only confirms that output exists. Callfprintwith patchedUSERandHOST, then assert that raw values are absent and placeholders are present.As per path instructions, “Ensure new or modified definitions will be covered by existing or new unit tests.”
🤖 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/config/test_print_info.py` around lines 22 - 25, Update test_print_info to patch USER and HOST with known raw values before calling print_debug_info, then assert the output excludes those values and includes the anonymization placeholders. Replace the output-length-only assertion while preserving coverage of the print_debug_info path.Source: Path instructions
🤖 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 `@monai/config/check_env.py`:
- Around line 163-167: Update the environment-reporting conditional around
print_environment_vars() and print_environment() to enter when either args.env
or args.envvars is set, while keeping variable output gated by args.envvars. Add
a CLI regression test covering --envvars without --env and ensure the modified
behavior is covered.
- Around line 102-150: Update check_torch and check_monai to catch runtime
exceptions from their diagnostic operations, report them with efprint, and
return False while preserving the existing ImportError handling. Move the full
check_torch_cuda workflow, including torch.cuda.device_count() and related
reporting, inside exception handling so pre-device CUDA failures are also
reported via efprint and return False.
---
Nitpick comments:
In `@monai/config/check_env.py`:
- Around line 57-150: Complete the Google-style docstrings for fprint,
print_environment, check_torch, check_torch_cuda, and check_monai in
monai/config/check_env.py: document fprint’s *args and **kwargs, and add Returns
sections describing the Boolean diagnostic results for each check function. Also
update fprint in monai/config/deviceconfig.py to document *args, **kwargs, and
its None return value; make no other behavioral changes.
In `@tests/config/test_print_info.py`:
- Around line 22-25: Update test_print_info to patch USER and HOST with known
raw values before calling print_debug_info, then assert the output excludes
those values and includes the anonymization placeholders. Replace the
output-length-only assertion while preserving coverage of the print_debug_info
path.
🪄 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: CHILL
Plan: Pro Plus
Run ID: 4ac837b2-74f0-41bc-9115-8d129c94eb8d
📒 Files selected for processing (7)
.github/workflows/cicd_tests.ymlMANIFEST.inmonai/config/__init__.pymonai/config/__main__.pymonai/config/check_env.pymonai/config/deviceconfig.pytests/config/test_print_info.py
💤 Files with no reviewable changes (1)
- monai/config/init.py
Fixes # .
Description
This adds a script to check the environment for installed libraries, if PyTorch works, if MONAI works, and print platform information. This script is meant to be useable without anything being installed other than Python itself, so it can be used to inspect an environment before attempting to install MONAI or produce diagnostic information when some environmental failure occurs. The script can be run remotely with
curlas it only relies on the standard library. Minor tweaks are made to the CI action to use this script rather than the copy-pasted short Python lines.Types of changes
./runtests.sh -f -u --net --coverage../runtests.sh --quick --unittests --disttests.make htmlcommand in thedocs/folder.