Skip to content

Commit

Permalink
Don't run comps without input
Browse files Browse the repository at this point in the history
  • Loading branch information
Willenbrink committed Jan 2, 2025
1 parent d758ae4 commit d7fe07b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 27 deletions.
23 changes: 0 additions & 23 deletions haystack/core/pipeline/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 4 additions & 4 deletions test/core/pipeline/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}")
Expand All @@ -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]})()
Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit d7fe07b

Please sign in to comment.