Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion haystack/core/pipeline/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,7 @@ def _get_next_runnable_component(

component_name = item[1]
comp = self._get_component_with_graph_metadata_and_visits(component_name, component_visits[component_name])
if comp["visits"] > self._max_runs_per_component:
if comp["visits"] >= self._max_runs_per_component:
msg = f"Maximum run count {self._max_runs_per_component} reached for component '{component_name}'"
raise PipelineMaxComponentRuns(msg)
return ComponentPriority(item[0]), component_name, comp
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
fixes:
- |
Fix an off-by-one error in ``max_runs_per_component`` so a component cannot run more
times than the configured limit within a single ``Pipeline.run()`` call.
4 changes: 2 additions & 2 deletions test/core/pipeline/test_pipeline_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1385,10 +1385,10 @@ def test__get_next_runnable_component_max_visits(self, mock_get_component_with_g
pipeline = PipelineBase(max_runs_per_component=2)
queue = FIFOPriorityQueue()
queue.push("ready_component", ComponentPriority.READY)
mock_get_component_with_graph_metadata_and_visits.return_value = {"instance": "test", "visits": 3}
mock_get_component_with_graph_metadata_and_visits.return_value = {"instance": "test", "visits": 2}

with pytest.raises(PipelineMaxComponentRuns) as exc_info:
pipeline._get_next_runnable_component(queue, component_visits={"ready_component": 3})
pipeline._get_next_runnable_component(queue, component_visits={"ready_component": 2})

assert "Maximum run count 2 reached for component 'ready_component'" in str(exc_info.value)
Comment thread
sjrl marked this conversation as resolved.

Expand Down
Loading