UN-2801 [FIX] Fix file batch distribution algorithm to respect configured batch limits#1537
Conversation
…ured batch limits Fixed an issue where the file batching algorithm was creating fewer batches than configured (16 instead of 30), causing uneven distribution of files across parallel workers. The new implementation ensures files are distributed as evenly as possible across the target number of batches. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Caution Review failedFailed to post review comments. Configuration used: CodeRabbit UI Review profile: CHILL Plan: Pro Cache: Disabled due to Reviews > Disable Cache setting Knowledge base: Disabled due to 📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
Summary by CodeRabbit
WalkthroughRefactors get_file_batches in workflow_helper.py to remove math usage, update docstring, and implement deterministic, even distribution of files into batches using remainder-based allocation while preventing empty batches. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Caller
participant Helper as WorkflowHelper.get_file_batches
Caller->>Helper: get_file_batches(file_items, BATCH_SIZE)
activate Helper
Note over Helper: Compute num_files, num_batches = min(BATCH_SIZE, num_files)
Helper->>Helper: base = num_files // num_batches<br/>rem = num_files % num_batches
loop Build batches (i = 0..num_batches-1)
alt i < rem
Note over Helper: batch_size = base + 1
else
Note over Helper: batch_size = base
end
Helper->>Helper: slice file_items[start:start+batch_size]
Note over Helper: Append non-empty batch
end
Helper-->>Caller: list[list[file_item]]
deactivate Helper
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Pre-merge checks and finishing touches and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
✨ Finishing touches
🧪 Generate unit tests
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. 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 |
|
|



Fixed an issue where the file batching algorithm was creating fewer batches than configured (16 instead of 30), causing uneven distribution of files across parallel workers. The new implementation ensures files are distributed as evenly as possible across the target number of batches.
🤖 Generated with Claude Code
What
Why
How
Can this PR break any existing features. If yes, please list possible items. If no, please explain why. (PS: Admins do not merge the PR without this section filled)
Database Migrations
Env Config
Relevant Docs
Related Issues or PRs
Dependencies Versions
Notes on Testing
Screenshots
Checklist
I have read and understood the Contribution Guidelines.