Skip to content

[Feature] Compare future results based on id#1013

Merged
jan-janssen merged 2 commits into
mainfrom
batched_futures_ids
Jun 10, 2026
Merged

[Feature] Compare future results based on id#1013
jan-janssen merged 2 commits into
mainfrom
batched_futures_ids

Conversation

@jan-janssen

@jan-janssen jan-janssen commented Jun 10, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Refactor
    • Optimized internal batch processing logic to improve performance when handling skipped items.

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The batched_futures function changes its skipped result filtering from value-based membership to identity-based comparison. Instead of flattening skip_lst and checking v.result() in skipped_elements_lst, it now builds a skipped_ids set using id(item) and filters using id(v.result()) membership.

Changes

Object Identity Filtering

Layer / File(s) Summary
Object identity filtering and n_expected adjustment
src/executorlib/standalone/batched.py
batched_futures builds a skipped_ids set from skip_lst using object identity (id(item)), updates n_expected to use set size, and filters completed futures by comparing id(v.result()) instead of checking value membership.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A batching rabbit hops with pride,
No longer checks the values wide—
Identity's the key, you see,
Each future finds its id() match with glee! 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: replacing value-based membership checking with identity-based comparison (id) when excluding skipped futures.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch batched_futures_ids

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.

@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.19%. Comparing base (49fca86) to head (10023c7).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 `@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

📥 Commits

Reviewing files that changed from the base of the PR and between 49fca86 and 10023c7.

📒 Files selected for processing (1)
  • src/executorlib/standalone/batched.py

Comment on lines +18 to +23
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:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

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_lst

Please 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]).

@jan-janssen
jan-janssen merged commit fd8b9a9 into main Jun 10, 2026
62 of 65 checks passed
@jan-janssen
jan-janssen deleted the batched_futures_ids branch June 10, 2026 14:41
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.

1 participant