diff --git a/haystack/core/errors.py b/haystack/core/errors.py index d241b13084..b312f67230 100644 --- a/haystack/core/errors.py +++ b/haystack/core/errors.py @@ -31,7 +31,10 @@ class PipelineDrawingError(PipelineError): class PipelineMaxLoops(PipelineError): # NOTE: This is shown also when importing PipelineMaxComponentRuns, I can't find an easy # way to fix this, so I will ignore that case. - warnings.warn("PipelineMaxLoops is deprecated; use PipelineMaxComponentRuns instead.", DeprecationWarning) + warnings.warn( + "PipelineMaxLoops is deprecated and will be remove in version '2.7.0'; use PipelineMaxComponentRuns instead.", + DeprecationWarning, + ) class PipelineMaxComponentRuns(PipelineMaxLoops): diff --git a/haystack/core/pipeline/base.py b/haystack/core/pipeline/base.py index af043928c1..727ebf58ff 100644 --- a/haystack/core/pipeline/base.py +++ b/haystack/core/pipeline/base.py @@ -42,6 +42,11 @@ logger = logging.getLogger(__name__) +_MAX_LOOPS_ALLOWED_DEPRECATION_MESSAGE = ( + "'max_loops_allowed' argument is deprecated and will be removed in version '2.7.0'. " + "Use 'max_runs_per_component' instead." +) + class PipelineBase: """ @@ -65,7 +70,7 @@ def __init__( this dictionary can be serialized and deserialized if you wish to save this `Pipeline` to file. :param max_loops_allowed: How many times the `Pipeline` can run the same node before throwing an exception. - This is deprecated, use `max_runs_per_component` instead. + This is deprecated and will be removed in version 2.7.0, use `max_runs_per_component` instead. :param debug_path: When debug is enabled in `run()`, where to save the debug data. :param max_runs_per_component: @@ -81,8 +86,7 @@ def __init__( self._debug_path = Path(debug_path) if max_loops_allowed is not None: - msg = "'max_loops_allowed' argument is deprecated. Use 'max_runs_per_component' instead." - warnings.warn(msg, DeprecationWarning) + warnings.warn(_MAX_LOOPS_ALLOWED_DEPRECATION_MESSAGE, DeprecationWarning) self._max_runs_per_component = max_loops_allowed else: self._max_runs_per_component = max_runs_per_component @@ -96,8 +100,7 @@ def max_loops_allowed(self) -> int: :return: Maximum number of runs per Component """ - msg = "'max_loops_allowed' argument is deprecated. Set 'max_runs_per_component' when initialising the Pipeline." - warnings.warn(msg, DeprecationWarning) + warnings.warn(_MAX_LOOPS_ALLOWED_DEPRECATION_MESSAGE, DeprecationWarning) return self._max_runs_per_component @max_loops_allowed.setter @@ -109,8 +112,7 @@ def max_loops_allowed(self, value: int): :param value: Maximum number of runs per Component """ - msg = "'max_loops_allowed' argument is deprecated. Set 'max_runs_per_component' when initialising the Pipeline." - warnings.warn(msg, DeprecationWarning) + warnings.warn(_MAX_LOOPS_ALLOWED_DEPRECATION_MESSAGE, DeprecationWarning) self._max_runs_per_component = value def __eq__(self, other) -> bool: diff --git a/releasenotes/notes/deprecate_max_loops_allowed-2b17a9b442b68199.yaml b/releasenotes/notes/deprecate_max_loops_allowed-2b17a9b442b68199.yaml index c140aca937..6cce5d8648 100644 --- a/releasenotes/notes/deprecate_max_loops_allowed-2b17a9b442b68199.yaml +++ b/releasenotes/notes/deprecate_max_loops_allowed-2b17a9b442b68199.yaml @@ -7,6 +7,6 @@ enhancements: Add new `PipelineMaxLoops` to reflect new `max_runs_per_component` init argument deprecations: - | - `Pipeline` init argument `max_loops_allowed` is deprecated in favor of `max_runs_per_component`. + `Pipeline` init argument `max_loops_allowed` is deprecated and will be remove in version `2.7.0`. Use `max_runs_per_component` instead. - | - `PipelineMaxLoops` exception is deprecated in favor of `PipelineMaxComponentRuns`. + `PipelineMaxLoops` exception is deprecated and will be remove in version `2.7.0`. Use `PipelineMaxComponentRuns` instead.