Skip to content

Commit 1d7bc77

Browse files
chore: deprecate PredefinedPipeline templates and PipelineTemplate (#10475)
* chore: deprecate PredefinedPipeline * move warning to PipelineTemplate --------- Co-authored-by: Julian Risch <julian.risch@deepset.ai>
1 parent c734baf commit 1d7bc77

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

haystack/core/pipeline/template.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from enum import Enum
66
from pathlib import Path
77
from typing import Any
8+
from warnings import warn
89

910
from jinja2 import PackageLoader, TemplateSyntaxError, meta
1011
from jinja2.sandbox import SandboxedEnvironment
@@ -75,6 +76,12 @@ def __init__(self, template_content: str):
7576
7677
:param template_content: The raw template source to use in the template.
7778
"""
79+
msg = (
80+
"`PipelineTemplate` and `PredefinedPipeline` are deprecated. "
81+
"They will be removed in Haystack version 2.25. "
82+
"Pipeline YAML files should be used instead."
83+
)
84+
warn(msg, DeprecationWarning, stacklevel=4)
7885
env = SandboxedEnvironment(
7986
loader=PackageLoader("haystack.core.pipeline", "predefined"), trim_blocks=True, lstrip_blocks=True
8087
)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
deprecations:
3+
- |
4+
Deprecated ``PipelineTemplate``, ``PredefinedPipeline`` and its options (like ``PredefinedPipeline.CHAT_WITH_WEBSITE``).
5+
These templates will be removed in Haystack 2.25. Users should switch to using Pipeline YAML files.

test/core/pipeline/test_templates.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ def test_from_predefined(self):
4747
tpl = PipelineTemplate.from_predefined(PredefinedPipeline.INDEXING)
4848
assert len(tpl.template_content)
4949

50+
def test_from_predefined_emits_deprecation_warning(self, monkeypatch):
51+
monkeypatch.setenv("OPENAI_API_KEY", "")
52+
with pytest.warns(DeprecationWarning, match="PipelineTemplate.*deprecated.*2\\.25"):
53+
PipelineTemplate.from_predefined(PredefinedPipeline.INDEXING)
54+
5055
# Building a pipeline directly using all default components specified in a predefined or custom template.
5156
def test_build_pipeline_with_default_components(self, monkeypatch):
5257
monkeypatch.setenv("OPENAI_API_KEY", "fake_key")

0 commit comments

Comments
 (0)