Skip to content

Commit

Permalink
Add version that will remove deprecate stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
silvanocerza committed Sep 11, 2024
1 parent 3610978 commit f2c88f6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
5 changes: 4 additions & 1 deletion haystack/core/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
16 changes: 9 additions & 7 deletions haystack/core/pipeline/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.

0 comments on commit f2c88f6

Please sign in to comment.