Skip to content

refactor: Refactor internals of AsyncPipeline#11431

Merged
sjrl merged 4 commits into
v3from
refactor-async-pipeline
May 29, 2026
Merged

refactor: Refactor internals of AsyncPipeline#11431
sjrl merged 4 commits into
v3from
refactor-async-pipeline

Conversation

@sjrl
Copy link
Copy Markdown
Contributor

@sjrl sjrl commented May 29, 2026

Related Issues

Proposed Changes:

  • Refactor internal methods to not use closures but explicit parameters. This should make it easier to understand and follow the logic of how the scheduling works.
  • Also try to align Pipeline and AsyncPipeline run methods as much as possible for consistency.

How did you test it?

Existing tests.

Notes for the reviewer

With this refactor I think we could more easily add parallel execution support to Pipeline.run using a thread pool executor by following the same scheduling logic as AsyncPipeline except replace asyncio calls with thread pool executor calls.

I think doing this for v3 could be a good time since we will have time to let the run logic be tested as we develop to potentially catch any issues.

Checklist

  • I have read the contributors guidelines and the code of conduct.
  • I have updated the related issue with new insights and changes.
  • I have added unit tests and updated the docstrings.
  • I've used one of the conventional commit types for my PR title: fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, test: and added ! in case the PR includes breaking changes.
  • I have documented my code.
  • I have added a release note file, following the contributors guidelines.
  • I have run pre-commit hooks and fixed any issue.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
haystack-docs Ignored Ignored Preview May 29, 2026 11:31am

Request Review

@sjrl sjrl self-assigned this May 29, 2026
@github-actions github-actions Bot added the type:documentation Improvements on the docs label May 29, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 29, 2026

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  haystack/core/pipeline
  async_pipeline.py 312, 498-502, 506, 523-527, 531-543, 582-591, 616
  pipeline.py 237
Project Total  

This report was generated by python-coverage-comment-action

@sjrl sjrl added the ignore-for-release-notes PRs with this flag won't be included in the release notes. label May 29, 2026
@sjrl sjrl changed the title refactor: Refactor AsyncPipeline refactor: Refactor internals of AsyncPipeline May 29, 2026
@sjrl sjrl marked this pull request as ready for review May 29, 2026 08:13
@sjrl sjrl requested a review from a team as a code owner May 29, 2026 08:13
@sjrl sjrl requested review from julian-risch and removed request for a team May 29, 2026 08:13
Copy link
Copy Markdown
Member

@julian-risch julian-risch left a comment

Choose a reason for hiding this comment

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

Looks good to me! Nothing against this refactoring from my side. Test coverage isn't great so that's something we could improve in future. Particularly, _run_component_in_isolation (previously _run_highest_in_isolation) would be worth testing in my opinion.

if partial_result:
yield {finished_component_name: _deepcopy_with_exceptions(partial_result)}

async def _run_component_in_isolation(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Now that this is an instance method, we could extend unit test coverage.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added some more in 0b8e0c5

@sjrl sjrl enabled auto-merge (squash) May 29, 2026 11:31
@sjrl sjrl merged commit c4b5146 into v3 May 29, 2026
24 of 25 checks passed
@sjrl sjrl deleted the refactor-async-pipeline branch May 29, 2026 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ignore-for-release-notes PRs with this flag won't be included in the release notes. topic:core topic:tests type:documentation Improvements on the docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants