Skip to content

Alphabetical ordering of auto-joined variadic inputs is unintuitive #10979

@bogdankostic

Description

@bogdankostic

Problem

When two or more components are automatically joined into a variadic list input (introduced in #10949), the order of items in the resulting list is not based on the order the components were connected but on the alphabetical order of the sender component names. This is unintuitive in my opinion.

Cause

In Pipeline.run(), components are scheduled in alphabetical order by name.

Example

@component
class StringProducer:
    def __init__(self, value: str = "Hello"):
        self.value = value

    @component.output_types(text=str)
    def run(self) -> dict[str, str]:
        return {"text": self.value}


@component
class ListStrProducer:
    def __init__(self, values: list[str] | None = None):
        self.values = values or ["Hello", "Hi"]

    @component.output_types(texts=list[str])
    def run(self) -> dict[str, list[str]]:
        return {"texts": self.values}

p = Pipeline()
p.add_component("str_producer", StringProducer("hello"))
p.add_component("list_producer", ListStrProducer(["world", "!"]))
p.add_component("receiver", ListStrAcceptor())
p.connect("str_producer.text", "receiver.texts")
p.connect("list_producer.texts", "receiver.texts")
result = p.run({})
assert result["receiver"]["result"] == ["world", "!", "hello"]

Options

A) Document the current behavior

Add a clear note to the connect() docstring and relevant user guide pages like Smart Pipeline Connections

B) Preserve connection order

Modify the pipeline connection logic to track the order in which connect() is called for a specific variadic socket. When gathering inputs during run(), sort the senders list by this chronological connection order rather than relying on the alphabetical execution order, aligning with standard user intuition.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium priority, add to the next sprint if no P1 available

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions