Skip to content

Fixing Requirements File Generation#783

Merged
ericspod merged 2 commits into
Project-MONAI:devfrom
ericspod:ci_requirements_file_fix
Jul 6, 2026
Merged

Fixing Requirements File Generation#783
ericspod merged 2 commits into
Project-MONAI:devfrom
ericspod:ci_requirements_file_fix

Conversation

@ericspod

@ericspod ericspod commented Jul 6, 2026

Copy link
Copy Markdown
Member

Description

This allows requirements files to be generated at test time from version in bundles which include range specifiers, eg "foo": ">=1.2.3". The bundle specification does not precisely say what the version specification should be thus it should be compatible with pip-style version specifiers of this format.

Status

Ready

Please ensure all the checkboxes:

  • Codeformat tests passed locally by running ./runtests.sh --codeformat.
  • In-line docstrings updated.
  • Update version and changelog in metadata.json if changing an existing bundle.
  • Please ensure the naming rules in config files meet our requirements (please refer to: CONTRIBUTING.md).
  • Ensure versions of packages such as monai, pytorch and numpy are correct in metadata.json.
  • Descriptions should be consistent with the content, such as eval_metrics of the provided weights and TorchScript modules.
  • Files larger than 25MB are excluded and replaced by providing download links in large_file.yml.
  • Avoid using path that contains personal information within config files (such as use /home/your_name/ for "bundle_root").

Summary by CodeRabbit

  • Bug Fixes
    • Improved bundle dependency requirement formatting.
    • Version strings are now trimmed of extra whitespace.
    • If a package version is blank, only the package name is emitted (no version constraint).
    • If a version already starts with an operator (for example <, >, =, !, ~), it’s preserved without adding redundant ==.
    • Produces cleaner, more accurate generated dependency specifications.

…perator

Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fe128e57-3af3-4fd7-b36e-ed5516d07cba

📥 Commits

Reviewing files that changed from the base of the PR and between 006add4 and 7d67e89.

📒 Files selected for processing (1)
  • ci/get_bundle_requirements.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • ci/get_bundle_requirements.py

Walkthrough

get_requirements now trims version values, skips special dependencies, and formats requirement strings based on whether a version is blank, operator-prefixed, or a plain version.

Changes

Requirement formatting

Layer / File(s) Summary
Version specifier formatting
ci/get_bundle_requirements.py
get_requirements now strips whitespace, handles blank versions, preserves operator-prefixed specifiers, and otherwise emits exact name==version strings while keeping the special dependency skip behavior.

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

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and clearly describes the main change to requirements file generation.
Description check ✅ Passed The description follows the template and includes the required summary, status, and checklist items.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

@ericspod ericspod changed the title Fixing Requirements File Generat Fixing Requirements File Generation Jul 6, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@ci/get_bundle_requirements.py`:
- Around line 86-92: Guard the bundle requirements parsing in
get_bundle_requirements.py so an empty stripped version never reaches
version[0], which can raise IndexError during requirements generation. In the
loop that builds version_line, add an explicit empty-string check after
version.strip() and handle it with a clear failure or skip path before
inspecting the first character. Also update the version formatting logic in this
block to avoid computing the default name==version string unless needed, and
keep the operator-detection behavior tied to the existing name, version, and
libs.append flow.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5c382a02-b26e-4351-8f72-b1dd5058316b

📥 Commits

Reviewing files that changed from the base of the PR and between 5121958 and 006add4.

📒 Files selected for processing (1)
  • ci/get_bundle_requirements.py

Comment thread ci/get_bundle_requirements.py Outdated
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
@ericspod ericspod merged commit d382e59 into Project-MONAI:dev Jul 6, 2026
4 checks passed
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.

2 participants