Skip to content

Commit

Permalink
wip: alternative warning
Browse files Browse the repository at this point in the history
  • Loading branch information
mathislucka committed Jan 16, 2025
1 parent ef8e754 commit 0252450
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions haystack/core/pipeline/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,15 +513,28 @@ def run( # noqa: PLR0915, PLR0912
},
) as span:
inputs = self._convert_from_legacy_format(pipeline_inputs=data)

self._warn_if_ambiguous_intent(
inputs=inputs, component_names=ordered_component_names, receivers=cached_receivers
)
priority_queue = self._fill_queue(ordered_component_names, inputs)

while True:
candidate = self._get_next_runnable_component(priority_queue)
if candidate is None:
break

_, component_name, component = candidate
priority, component_name, component = candidate
if len(priority_queue) > 0:
next_priority, next_name = priority_queue.peek()

# alternative to _warn_if_ambiguous_intent
if priority in [ComponentPriority.DEFER, ComponentPriority.DEFER_LAST] and next_priority == priority:
msg = (
f"Ambiguous running order: Components '{component_name}' and '{next_name}' are waiting for "
f"optional inputs at the same time. Component '{component_name}' executes first."
)
warnings.warn(msg)

component_outputs, inputs = self._run_component(component, inputs, parent_span=span)
component_pipeline_outputs, inputs = self._write_component_outputs(
component_name=component_name,
Expand Down

0 comments on commit 0252450

Please sign in to comment.