[Feature] Compare future results based on id#1013
Conversation
📝 WalkthroughWalkthroughThe ChangesObject Identity Filtering
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1013 +/- ##
=======================================
Coverage 94.19% 94.19%
=======================================
Files 39 39
Lines 2103 2103
=======================================
Hits 1981 1981
Misses 122 122 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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 `@src/executorlib/standalone/batched.py`:
- Around line 18-23: The current calculation of n_expected uses len(skipped_ids)
which undercounts when skip_lst contains duplicate identities; change the logic
to count actual skipped occurrences in lst instead of unique ids: compute
skipped_count = sum(1 for v in lst if id(v.result()) in skipped_ids) and set
n_expected = min(n, len(lst) - skipped_count). Update references to skipped_ids,
skip_lst, n_expected, lst and done_lst in the function to use skipped_count, and
add a regression test case where lst results include duplicated identities
(e.g., values [1,1,2] with n=2 and skip_lst=[[1,1]] should yield [2]).
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: 86c296d8-7d79-46a5-a4e8-4859ce840223
📒 Files selected for processing (1)
src/executorlib/standalone/batched.py
| skipped_ids = {id(item) for items in skip_lst for item in items} | ||
|
|
||
| done_lst = [] | ||
| n_expected = min(n, len(lst) - len(skipped_elements_lst)) | ||
| n_expected = min(n, len(lst) - len(skipped_ids)) | ||
| for v in lst: | ||
| if v.done() and v.result() not in skipped_elements_lst: | ||
| if v.done() and id(v.result()) not in skipped_ids: |
There was a problem hiding this comment.
n_expected is now derived from unique IDs, which can block final batch emission.
On Line 21, len(skipped_ids) undercounts consumed results when skipped batches include duplicate identities (common with shared objects/singletons). That can make n_expected too large, so Line 25 never triggers and this function returns [] even when only the tail batch remains.
Suggested fix
- skipped_ids = {id(item) for items in skip_lst for item in items}
+ skipped_items = [item for items in skip_lst for item in items]
+ skipped_ids = {id(item) for item in skipped_items}
done_lst = []
- n_expected = min(n, len(lst) - len(skipped_ids))
+ n_expected = min(n, len(lst) - len(skipped_items))
for v in lst:
- if v.done() and id(v.result()) not in skipped_ids:
- done_lst.append(v.result())
+ if v.done():
+ result = v.result()
+ if id(result) not in skipped_ids:
+ done_lst.append(result)
if len(done_lst) == n_expected:
return done_lstPlease also add a regression case like duplicated skipped identities ([1, 1, 2] with n=2, then skip_lst=[[1,1]] should yield [2]).
🤖 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 `@src/executorlib/standalone/batched.py` around lines 18 - 23, The current
calculation of n_expected uses len(skipped_ids) which undercounts when skip_lst
contains duplicate identities; change the logic to count actual skipped
occurrences in lst instead of unique ids: compute skipped_count = sum(1 for v in
lst if id(v.result()) in skipped_ids) and set n_expected = min(n, len(lst) -
skipped_count). Update references to skipped_ids, skip_lst, n_expected, lst and
done_lst in the function to use skipped_count, and add a regression test case
where lst results include duplicated identities (e.g., values [1,1,2] with n=2
and skip_lst=[[1,1]] should yield [2]).
Summary by CodeRabbit