Skip to content

fix: adapt optimum, ragas, elasticsearch, opensearch to APIs removed in Haystack 3.0#3538

Merged
julian-risch merged 4 commits into
mainfrom
fix/removed-apis-v3-compat
Jul 3, 2026
Merged

fix: adapt optimum, ragas, elasticsearch, opensearch to APIs removed in Haystack 3.0#3538
julian-risch merged 4 commits into
mainfrom
fix/removed-apis-v3-compat

Conversation

@julian-risch

@julian-risch julian-risch commented Jul 2, 2026

Copy link
Copy Markdown
Member

Related Issues

  • Part of deepset-ai/haystack-private#446

Haystack 3.0 removes several APIs some of our integrations relied on.

Proposed Changes:

  • optimum (src): HFModelType and check_valid_model were removed from haystack.utils.hf, so the package failed to import at all under 3.0 (mypy errors plus collection errors in every embedder test module). Both are now vendored into _backend.py verbatim — they are small, HF-specific helpers, and vendoring keeps behavior identical on both versions with no conditional imports. The existing tests keep patching _backend.check_valid_model unchanged.
  • ragas (tests): AsyncPipeline no longer exists at the haystack top level; 3.0 merged async execution into Pipeline (run_async). The test module now falls back to AsyncPipeline = Pipeline on ImportError.
  • elasticsearch, opensearch (tests): the hybrid-retriever serde tests built a real SentenceTransformersTextEmbedder, which 3.0 removed from core. They now use OpenAITextEmbedder (in core on both versions) and build the expected embedder sub-dict with embedder.to_dict() at runtime instead of hard-coding it — which also removes the device/revision compat shims those hard-coded dicts had accumulated. An autouse fixture sets a fake OPENAI_API_KEY, since haystack-ai 2.x resolves the key eagerly at init.

How did you test it?

  • Haystack 2.x unit tests pass for all four integrations.
  • Haystack v3 branch (installed git+https://github.com/deepset-ai/haystack.git@v3 into the test envs): mypy is clean and unit tests pass

Notes for the reviewer

If we prefer not to vendor check_valid_model into optimum, then the alternative is dropping Hub-side model validation entirely and letting the model load fail naturally. The advantage of vendoring is that it preserves today's error messages for users.

The SentenceTransformers* mentions remaining in elasticsearch/opensearch src are docstring usage examples only (no runtime imports); updating those examples for the 3.0 component locations is a docs follow-up.

Checklist

🤖 Generated with Claude Code

- optimum: vendor HFModelType and check_valid_model, removed from
  haystack.utils.hf in 3.0; the package previously failed to import.
- ragas tests: alias AsyncPipeline to Pipeline when the import fails;
  3.0 merged async execution into Pipeline (run_async).
- elasticsearch/opensearch tests: the hybrid-retriever serde tests used
  SentenceTransformersTextEmbedder, which 3.0 removed from core. Use
  OpenAITextEmbedder (available in both versions) and build the expected
  embedder dict with to_dict() at runtime, which also removes the
  device/revision compat shims the hard-coded dicts had accumulated.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Coverage report (elasticsearch)

This PR does not seem to contain any modification to coverable code.

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Coverage report (opensearch)

This PR does not seem to contain any modification to coverable code.

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Coverage report (ragas)

This PR does not seem to contain any modification to coverable code.

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Coverage report (optimum)

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  integrations/optimum/src/haystack_integrations/components/embedders/optimum
  _backend.py 51-60
Project Total  

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

@julian-risch julian-risch marked this pull request as ready for review July 2, 2026 15:39
@julian-risch julian-risch requested a review from a team as a code owner July 2, 2026 15:39
@julian-risch julian-risch requested review from bogdankostic and removed request for a team July 2, 2026 15:39

@bogdankostic bogdankostic 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 in general, just some minor comments.

Comment thread integrations/elasticsearch/tests/test_hybrid_retriever.py Outdated
julian-risch and others added 2 commits July 3, 2026 10:52
…dders/optimum/_backend.py

Co-authored-by: bogdankostic <bogdankostic@web.de>
- optimum: the vendored check_valid_model only needs the embedding branch,
  so drop the HFModelType enum and validate embedding models directly.
- elasticsearch/opensearch hybrid retriever tests: pin the expected
  OpenAITextEmbedder dict instead of building it from to_dict(), which made
  the comparison a tautology; its serialization format is identical on
  haystack-ai 2.x and 3.x.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@julian-risch julian-risch requested a review from bogdankostic July 3, 2026 09:51
@julian-risch julian-risch merged commit aacc089 into main Jul 3, 2026
32 checks passed
@julian-risch julian-risch deleted the fix/removed-apis-v3-compat branch July 3, 2026 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants