Skip to content

Check Environment Script - #9038

Draft
ericspod wants to merge 11 commits into
Project-MONAI:devfrom
ericspod:check_env
Draft

Check Environment Script#9038
ericspod wants to merge 11 commits into
Project-MONAI:devfrom
ericspod:check_env

Conversation

@ericspod

@ericspod ericspod commented Aug 1, 2026

Copy link
Copy Markdown
Member

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 curl as 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

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • Breaking change (fix or new feature that would cause existing functionality to change).
  • New tests added to cover the changes.
  • Integration tests passed locally by running ./runtests.sh -f -u --net --coverage.
  • Quick tests passed locally by running ./runtests.sh --quick --unittests --disttests.
  • In-line docstrings updated.
  • Documentation updated, tested make html command in the docs/ folder.

ericspod added 5 commits July 30, 2026 13:28
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>
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 16728a5c-2825-4c12-8b73-a6f263038bc4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The 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 IgniteInfo export is removed. Module execution and package manifest support are added. CI uses the new diagnostics for test and distribution validation.

Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: adding an environment-checking script.
Description check ✅ Passed The description explains the script, its purpose, CI updates, and change types using the required template.
Docstring Coverage ✅ Passed Docstring coverage is 86.67% which is sufficient. The required threshold is 80.00%.
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.
✨ 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.

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>
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>

@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: 2

🧹 Nitpick comments (2)
monai/config/check_env.py (1)

57-150: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Complete the new utility docstrings.

  • monai/config/check_env.py#L57-L150: Document *args and **kwargs for fprint. Add Returns sections for Boolean diagnostic checks.
  • monai/config/deviceconfig.py#L54-L61: Document *args, **kwargs, and the None return value for fprint.

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 win

Test the anonymization contract.

out.tell() only confirms that output exists. Call fprint with patched USER and HOST, 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

📥 Commits

Reviewing files that changed from the base of the PR and between 8690ae7 and d8b3ffd.

📒 Files selected for processing (7)
  • .github/workflows/cicd_tests.yml
  • MANIFEST.in
  • monai/config/__init__.py
  • monai/config/__main__.py
  • monai/config/check_env.py
  • monai/config/deviceconfig.py
  • tests/config/test_print_info.py
💤 Files with no reviewable changes (1)
  • monai/config/init.py

Comment thread monai/config/check_env.py
Comment thread monai/config/check_env.py
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
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