From d7fe07ba76b48e9c6e24b20cd3fa96819419cd85 Mon Sep 17 00:00:00 2001 From: Sebastian Willenbrink Date: Thu, 2 Jan 2025 17:30:23 +0100 Subject: [PATCH] Don't run comps without input --- haystack/core/pipeline/base.py | 23 ----------------------- test/core/pipeline/test_pipeline.py | 8 ++++---- 2 files changed, 4 insertions(+), 27 deletions(-) diff --git a/haystack/core/pipeline/base.py b/haystack/core/pipeline/base.py index c5dc4fda85..d350cf008a 100644 --- a/haystack/core/pipeline/base.py +++ b/haystack/core/pipeline/base.py @@ -986,29 +986,6 @@ def count_inputs(name, comp): if first_lazy_variadic: return first_lazy_variadic - # Return components that get no input at all but have default arguments - first_default_lazy_variadic = next( - ( - (name, comp) - for (name, comp, lazy_variadic, num_inputs) in waiting_queue - if lazy_variadic and num_inputs is not None - ), - None, - ) - if first_default_lazy_variadic: - return first_default_lazy_variadic - - first_default = next( - ( - (name, comp) - for (name, comp, lazy_variadic, num_inputs) in waiting_queue - if not lazy_variadic and num_inputs is not None - ), - None, - ) - if first_default: - return first_default - return None def _find_next_runnable_lazy_variadic_or_default_component( diff --git a/test/core/pipeline/test_pipeline.py b/test/core/pipeline/test_pipeline.py index 2b1ed38e5e..efa50ad13e 100644 --- a/test/core/pipeline/test_pipeline.py +++ b/test/core/pipeline/test_pipeline.py @@ -1223,7 +1223,7 @@ def test__find_next_runnable_component_with_component_with_only_variadic_non_gre components_inputs = {} waiting_queue = [("document_joiner", document_joiner)] pair = pipe._find_next_runnable_component(components_inputs, waiting_queue) - assert pair == ("document_joiner", document_joiner) + assert pair == None def test__find_next_runnable_component_with_component_with_only_default_input(self): prompt_builder = PromptBuilder(template="{{ questions | join('\n') }}") @@ -1233,7 +1233,7 @@ def test__find_next_runnable_component_with_component_with_only_default_input(se waiting_queue = [("prompt_builder", prompt_builder)] pair = pipe._find_next_runnable_component(components_inputs, waiting_queue) - assert pair == ("prompt_builder", prompt_builder) + assert pair == None def test__find_next_runnable_component_with_component_with_variadic_non_greedy_and_default_input(self): document_joiner = component_class("DocumentJoiner", input_types={"docs": Variadic[Document]})() @@ -1244,7 +1244,7 @@ def test__find_next_runnable_component_with_component_with_variadic_non_greedy_a waiting_queue = [("prompt_builder", prompt_builder), ("document_joiner", document_joiner)] pair = pipe._find_next_runnable_component(components_inputs, waiting_queue) - assert pair == ("document_joiner", document_joiner) + assert pair == None def test__find_next_runnable_component_with_different_components_inputs(self): document_builder = component_class( @@ -1280,7 +1280,7 @@ def test__find_next_runnable_component_with_different_components_without_any_inp ] pair = pipe._find_next_runnable_component(components_inputs, waiting_queue) - assert pair == ("document_joiner", document_joiner) + assert pair == None def test__is_stuck_in_a_loop(self): document_builder = component_class(