Skip to content

Support duck-typed Futures in task graph processing#12213

Merged
mrocklin merged 1 commit intodask:mainfrom
mrocklin:duck-typed-futures
Jan 7, 2026
Merged

Support duck-typed Futures in task graph processing#12213
mrocklin merged 1 commit intodask:mainfrom
mrocklin:duck-typed-futures

Conversation

@mrocklin
Copy link
Copy Markdown
Member

I'm curious about experimenting with other schedulers aside from dask.distributed. This change allows a bit more extensibility for both Clients and Futures by opening things up to duck typing. This is backwards compatible. Performance impact is negligible.

Add _is_dask_future() helper to detect both TaskRef instances and duck-typed futures (objects with dask_future = True). This allows third-party schedulers to use their own Future classes with dask.persist() and graph conversion.

Changes:

  • Add _is_dask_future() helper function
  • Update parse_input() to convert duck-typed futures to Alias
  • Update convert_legacy_task() to handle duck-typed futures
  • Update _get_dependencies() to extract keys from duck-typed futures
  • Generalize persist protocol in base.py for any scheduler with a persist method

🤖 Generated with Claude Code

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 31, 2025

Unit Test Results

See test report for an extended history of previous test failures. This is useful for diagnosing flaky tests.

     11 files  ±0       11 suites  ±0   3h 34m 46s ⏱️ + 6m 57s
 18 161 tests ±0   16 945 ✅ ±0   1 216 💤 ±0  0 ❌ ±0 
198 738 runs  ±0  183 972 ✅ +2  14 766 💤  - 2  0 ❌ ±0 

Results for commit 66c78aa. ± Comparison against base commit 1e27392.

♻️ This comment has been updated with latest results.

Add _is_dask_future() helper to detect both TaskRef instances and
duck-typed futures (objects with __dask_future__ = True). This allows
third-party schedulers to use their own Future classes with dask.persist()
and graph conversion.

Changes:
- Add _is_dask_future() helper function
- Update parse_input() to convert duck-typed futures to Alias
- Update convert_legacy_task() to handle duck-typed futures
- Update _get_dependencies() to extract keys from duck-typed futures
- Generalize persist protocol in base.py for any scheduler with a persist method

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@mrocklin mrocklin force-pushed the duck-typed-futures branch from b3e5a45 to 66c78aa Compare January 2, 2026 14:30
Copy link
Copy Markdown
Collaborator

@dcherian dcherian left a comment

Choose a reason for hiding this comment

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

Seems fine to me.

@mrocklin mrocklin merged commit 5ea912c into dask:main Jan 7, 2026
26 of 27 checks passed
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.

2 participants