Skip to content

feat: add component lifecycle handling#11675

Merged
anakin87 merged 17 commits into
v3from
lifecycle
Jun 23, 2026
Merged

feat: add component lifecycle handling#11675
anakin87 merged 17 commits into
v3from
lifecycle

Conversation

@anakin87

@anakin87 anakin87 commented Jun 18, 2026

Copy link
Copy Markdown
Member

Related Issues

Proposed Changes:

Discussed in https://github.com/deepset-ai/haystack-private/issues/384#issuecomment-4740431488

How did you test it?

  • CI, new tests
  • opened a PR on core integrations to spot issues in the inheriting components from touched OpenAI components: try lifecycle Haystack branch haystack-core-integrations#3467
    • several failures, also unrelated (I think we should start testing v3 branch soon on core integrations)
    • took a look at failures related to modified OpenAI components: I think we might fix them with some if/else to temporarily be compatible with Haystack 2.x and 3.x
  • also tried to implement the new lifecycle handling approach to other integrations (Bedrock, Nvidia and Sentence Transformers) to see if it holds and it turned out to be feasible

Notes for the reviewer

This PR is big. I created a single one to test everything.
Once we agree on the general approach, I'd be happy to split it into smaller parts if you prefer.

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

vercel Bot commented Jun 18, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
haystack-docs Ready Ready Preview, Comment Jun 23, 2026 1:48pm

Request Review

@anakin87 anakin87 changed the base branch from main to v3 June 18, 2026 08:47
@github-actions github-actions Bot added the type:documentation Improvements on the docs label Jun 18, 2026
@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  haystack/components/agents
  agent.py
  haystack/components/embedders
  azure_document_embedder.py
  azure_text_embedder.py
  openai_document_embedder.py 250, 295-302, 375-379
  openai_text_embedder.py 221-223, 241-245
  haystack/components/evaluators
  llm_evaluator.py
  haystack/components/extractors
  llm_metadata_extractor.py
  haystack/components/extractors/image
  llm_document_content_extractor.py
  haystack/components/fetchers
  link_content.py 192-200, 267
  haystack/components/generators
  openai_image_generator.py
  haystack/components/generators/chat
  azure.py 213
  fallback.py
  openai.py
  openai_responses.py
  haystack/components/preprocessors
  embedding_based_document_splitter.py
  recursive_splitter.py
  haystack/components/query
  query_expander.py
  haystack/components/rankers
  llm_ranker.py 320-321
  haystack/components/retrievers
  multi_query_embedding_retriever.py
  multi_query_text_retriever.py
  multi_retriever.py
  haystack/components/routers
  llm_messages_router.py
  haystack/core/pipeline
  base.py
  pipeline.py
  haystack/core/super_component
  super_component.py 67
Project Total  

The report is truncated to 25 files out of 26. To see the full report, please visit the workflow summary page.

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

@anakin87 anakin87 changed the title Lifecycle POC feat: add component lifecycle handling Jun 18, 2026
@anakin87 anakin87 marked this pull request as ready for review June 18, 2026 14:53
@anakin87 anakin87 requested a review from a team as a code owner June 18, 2026 14:53
@anakin87 anakin87 requested review from bogdankostic, mpangrazzi and sjrl and removed request for a team and bogdankostic June 18, 2026 14:53
Comment thread haystack/components/audio/whisper_remote.py Outdated
Comment thread haystack/core/pipeline/base.py Outdated
Comment thread haystack/core/pipeline/base.py Outdated
Comment thread test/components/agents/test_agent.py Outdated
Comment thread test/core/pipeline/test_pipeline_lifecycle.py Outdated
Comment thread test/core/pipeline/test_pipeline_lifecycle.py Outdated
@anakin87 anakin87 requested a review from a team as a code owner June 19, 2026 10:11
Comment thread haystack/components/agents/agent.py

@sjrl sjrl 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.

Looks good! Would be nice if @mpangrazzi could also give it a lookover before merging

@sjrl sjrl mentioned this pull request Jun 22, 2026
7 tasks

@mpangrazzi mpangrazzi 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.

Looks good! I've left a minor comment, your choice if to handle it or not.

"""
Warms up the SuperComponent by warming up the wrapped pipeline on the serving event loop.
"""
if not self._warmed_up:

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.

Minor thing, but I was thinking that warm_up_async and warm_up are relying on a single self._warmed_up flag.

One could expect that warm_up warms up sync resources (ie sync client), and warm_up_async the async ones. So this single flag could be a bit inconsistent with other components behaviour. WDYT?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good point. I'll fix this.

@claude

claude Bot commented Jun 23, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@claude

claude Bot commented Jun 23, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@anakin87 anakin87 merged commit 7b77eb9 into v3 Jun 23, 2026
27 checks passed
@anakin87 anakin87 deleted the lifecycle branch June 23, 2026 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants