Skip to content

feat(cli): support multiple constraints files via repeated -c flag#1128

Draft
smoparth wants to merge 1 commit intomainfrom
feat/multiple-constraints-files
Draft

feat(cli): support multiple constraints files via repeated -c flag#1128
smoparth wants to merge 1 commit intomainfrom
feat/multiple-constraints-files

Conversation

@smoparth
Copy link
Copy Markdown
Contributor

@smoparth smoparth commented May 8, 2026

  • Add multiple=True to the -c/--constraints-file global CLI option
  • Update WorkContext to load multiple constraint files (local paths or remote URIs)
  • Rewrite pip_constraint_args to write a single merged constraints file for uv

Closes: #1096

Pull Request Description

What

Why

@smoparth smoparth requested a review from a team as a code owner May 8, 2026 15:15
@mergify mergify Bot added the ci label May 8, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 8, 2026

Review Change Stack

Warning

Rate limit exceeded

@smoparth has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 49 minutes and 34 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: de787ccc-abe3-439b-80c7-f0e56d480528

📥 Commits

Reviewing files that changed from the base of the PR and between dd7009b and ab7325e.

📒 Files selected for processing (4)
  • src/fromager/__main__.py
  • src/fromager/context.py
  • tests/test_cli.py
  • tests/test_context.py
📝 Walkthrough

Walkthrough

This PR implements support for multiple constraints files in the fromager CLI. The --constraints-file option now accepts multiple values via Click's multiple=True parameter. WorkContext is updated to store a list of constraint file URIs instead of a single URI, loading each into self.constraints. The pip_constraint_args property now generates a merged input-constraints.txt file from all loaded constraints and returns the appropriate --constraint flag. HTTP/remote URL fetching logic for constraints is removed. CLI and context tests are added to validate the merging behavior with both single and multiple constraint files.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding support for multiple constraints files via the repeated -c flag in the CLI.
Description check ✅ Passed The description is related to the changeset, mentioning multiple constraints files, WorkContext updates, and merging constraints, though it lacks detailed explanation of the implementation.
Linked Issues check ✅ Passed The PR implements both objectives from issue #1096: updating the CLI to accept multiple constraints files (multiple=True on -c option) and updating WorkContext to load and merge constraints from all provided files.
Out of Scope Changes check ✅ Passed All changes are in scope: CLI option update, WorkContext refactoring to handle multiple files, pip_constraint_args adaptation, and test coverage for the new functionality.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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 `@src/fromager/context.py`:
- Around line 143-150: The current logic skips writing input-constraints.txt if
it already exists, which can leave stale constraints in self.work_dir; change
the block that computes path_to_constraints_file and the lines list to always
write the merged constraints file (i.e., remove the exists() guard) so that
path_to_constraints_file.write_text("".join(lines)) runs on every invocation;
use the existing self.constraints.get_constraint(constraint_name) loop to
rebuild the contents before writing to input-constraints.txt.

In `@tests/test_context.py`:
- Around line 59-71: Update the test_pip_constraints_args_multiple_files
assertion to verify both constraint files contributed by checking the merged
file contains the numpy lower and upper bounds together and that numpy appears
only once: after ctx.setup() read merged_path and assert "numpy>=1.24" in
content, assert "numpy<2.0" in content, assert content.count("numpy") == 1, and
still assert "requests" is present and ctx.pip_constraint_args equals
["--constraint", os.fspath(merged_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

Run ID: 72076441-bf4d-447a-a6fa-ec6931bdafd3

📥 Commits

Reviewing files that changed from the base of the PR and between b30aae7 and dd7009b.

📒 Files selected for processing (4)
  • src/fromager/__main__.py
  • src/fromager/context.py
  • tests/test_cli.py
  • tests/test_context.py

Comment thread src/fromager/context.py Outdated
Comment thread tests/test_context.py Outdated
Add `multiple=True` to the global `-c`/`--constraints-file` Click option
so users can pass multiple constraint sources (local files or remote
URIs). WorkContext now loads all provided files in sequence, merging
constraints via the combining logic added in #1125. The `pip_constraint_args`
property writes a single merged constraints file for uv instead of
passing the raw input file.

Closes: #1096

Co-Authored-By: Claude <claude@anthropic.com>
Signed-off-by: Shanmukh Pawan <smoparth@redhat.com>
@smoparth smoparth force-pushed the feat/multiple-constraints-files branch from dd7009b to ab7325e Compare May 8, 2026 15:26
@smoparth smoparth deployed to release May 8, 2026 15:26 — with GitHub Actions Active
@smoparth smoparth marked this pull request as draft May 8, 2026 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support multiple constraints and constraint files

1 participant