Skip to content

Commit b390210

Browse files
committed
docs: clarify Pipeline vs AsyncPipeline variadic ordering
Applied sjrl's review feedback. The previous text was wrong about DocumentJoiner (it behaves the same as a promoted variadic socket) and it missed the difference between Pipeline and AsyncPipeline. Pipeline schedules components alphabetically, so the resulting list is ordered by sender name. AsyncPipeline runs branches in parallel, so ordering is not guaranteed. Updated both the connect() docstring and the _make_socket_auto_variadic note, plus the release note.
1 parent a160b45 commit b390210

2 files changed

Lines changed: 19 additions & 18 deletions

File tree

haystack/core/pipeline/base.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -446,12 +446,11 @@ def connect(self, sender: str, receiver: str) -> "PipelineBase": # noqa: PLR091
446446
If connecting to a component that has several output connections, specify the inputs and output names as
447447
'component_name.connections_name'.
448448
449-
When multiple senders are connected to the same list-typed receiver socket, the socket is
450-
automatically promoted to a lazy-variadic socket so it can accept all of them. The items
451-
in the resulting list are ordered by sender component name (alphabetically), not by the
452-
order in which ``connect()`` was called. If your downstream component depends on a specific
453-
input order, use a dedicated joiner component (for example ``DocumentJoiner``) that lets
454-
you control ordering explicitly.
449+
If multiple senders are connected to the same list-typed receiver socket, the socket is
450+
promoted to a lazy variadic socket so it can accept all incoming values. With ``Pipeline``,
451+
the resulting list is ordered alphabetically by sender component name, not by the order in
452+
which ``connect()`` was called. With ``AsyncPipeline``, no ordering is guaranteed, since
453+
components in different branches may run in parallel.
455454
456455
:param sender:
457456
The component that delivers the value. This can be either just a component name or can be
@@ -964,13 +963,13 @@ def _make_socket_auto_variadic(
964963
the receiver socket's declared list type directly.
965964
966965
.. note::
967-
When multiple senders are connected to the same auto-variadic socket, the items
968-
in the resulting list are ordered by sender component name (alphabetically), not by
969-
the order in which the connections were declared via ``connect()``. This is because
970-
``Pipeline.run()`` schedules components in alphabetical order so that execution is
971-
deterministic and independent of pipeline insertion order. If your downstream
972-
component is sensitive to the input order, consider using a dedicated joiner
973-
component that lets you control ordering explicitly.
966+
When multiple senders are connected to the same auto-variadic socket, ordering
967+
depends on the pipeline class. ``Pipeline.run()`` schedules components
968+
alphabetically by name, so the resulting list is ordered alphabetically by sender
969+
name rather than by the order of ``connect()`` calls. ``AsyncPipeline`` does not
970+
guarantee any ordering, since components in different branches may run in parallel.
971+
If your downstream component is sensitive to input order, consider using a
972+
dedicated joiner component that lets you control ordering explicitly.
974973
975974
:param component_name:
976975
Name of the component owning the receiver socket, used in error messages.

releasenotes/notes/document-variadic-input-ordering-530d8feee4a1b900.yaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ enhancements:
33
- |
44
Document the input ordering behavior of auto-promoted lazy variadic sockets in
55
``Pipeline.connect()`` and ``PipelineBase._make_socket_auto_variadic()``. When
6-
multiple senders are connected to the same list-typed receiver socket, the items
7-
in the resulting list are ordered alphabetically by sender component name (because
8-
``Pipeline.run()`` schedules components in alphabetical order for deterministic
9-
execution), not by the order in which ``connect()`` was called. The docstrings now
10-
point users to a dedicated joiner component when they need explicit ordering.
6+
multiple senders are connected to the same list-typed receiver socket, ordering
7+
depends on the pipeline class. With ``Pipeline``, items are ordered alphabetically
8+
by sender component name (because ``Pipeline.run()`` schedules components in
9+
alphabetical order for deterministic execution), not by the order of ``connect()``
10+
calls. With ``AsyncPipeline``, no ordering is guaranteed, since components in
11+
different branches may run in parallel. The docstrings now point users to a
12+
dedicated joiner component when they need explicit ordering.

0 commit comments

Comments
 (0)