Repository navigation
Conversation
Evaluate the full candidate range up to max_cluster and guard the single-cluster edge case so _get_optimal_clusters does not crash when max_cluster resolves to 1. Add regression tests to cover the max_cluster=1 path and verify the upper-bound candidate is evaluated. Co-authored-by: Cursor <[email protected]>
|
Thanks for reviewing! Could a maintainer please add the |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
ChangesOptimal Cluster Selection Fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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: 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 `@rag/raptor.py`:
- Around line 238-239: The early-return path when max_clusters <= 1 lacks
logging, making single-cluster selection invisible in runtime diagnostics. Add a
log statement before the return statement inside the if max_clusters <= 1
condition to record when this branch is taken, including the max_clusters value
and the input size for observability and debugging purposes.
🪄 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: d0365571-3936-4b78-906e-57add3b04c77
📒 Files selected for processing (2)
rag/raptor.pytest/unit_test/rag/test_raptor_psi_tree_builder.py
|
Friendly follow-up: could a maintainer please add the |
|
Hi maintainers, quick follow-up on this one. The PR is non-draft and mergeable, but the test workflow is still skipped without the |
Log the max cluster and embedding count when RAPTOR skips GMM model selection because only one cluster is available.
|
Addressed the CodeRabbit feedback by adding logging for the single-cluster RAPTOR GMM fallback path. Validated locally with:
Result: 18 passed. The PR is still non-draft and mergeable. Could a maintainer please add the |
|
Friendly follow-up: this PR is ready for review with all checks passing. When you have a moment, could you please take a look? Thanks for your time! |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16199 +/- ##
=======================================
Coverage 93.16% 93.16%
=======================================
Files 10 10
Lines 717 717
Branches 118 118
=======================================
Hits 668 668
Misses 29 29
Partials 20 20 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
What problem does this PR solve?
_get_optimal_clustersinrag/raptor.pyhad two edge-case issues in GMM cluster-count selection:np.arange(1, max_clusters), which never evaluates the upper-bound candidate (max_clusters).max_clustersbecomes1, the candidate list was empty andargmincrashed.This PR makes candidate evaluation inclusive (
1..max_clusters) and guards the single-cluster case by returning1directly.Type of change
Validation
pytest test/unit_test/rag/test_raptor_psi_tree_builder.py --config-file pyproject.toml -qruff check rag/raptor.py test/unit_test/rag/test_raptor_psi_tree_builder.pyTests added
max_cluster == 1path (no crash, returns 1)AI-assistance disclosure: parts of this change (bug triage and test scaffolding) were drafted with AI assistance and fully reviewed and verified by me.