Skip to content

Introspection fails for blocks with carrier port labels #341

Closed

Description

@milanofthe

#253 adds Carrier and Vector as port label values, so a block can declare input_port_labels = {"in": Species()} with a carrier covering several channels.

process_port_labels in scripts/pathview_introspect.py sorts the labels by value:

return [name for name, _ in sorted(labels.items(), key=lambda x: x[1])]

With a carrier among the values, the comparison between a Carrier and an int raises a TypeError, so introspection fails for any block that uses carriers. extract.py has the same pattern in _process_port_labels.

Carrier ports should be read with their channel layout (start, size, keys) and drawn as one port, which is what #332 asks for. Until then introspection should at least not fail, e.g. by sorting on start for carriers. This is needed before toolbox blocks (pathsim-fusion) can use carriers.

Activity

  1. milanofthe commented on Nov 10, 2026

    @milanofthe
    MemberAuthor

    Plan:

    1. Introspection reads a Carrier port label as one port with its layout (start, size, keys), ports ordered by start. Fixes the TypeError in process_port_labels and extract.py.
    2. Carrier ports are bus ports. A carrier output is a bus source whose elements are the carrier's keys (positions for a Vector), a carrier input expects a bus with exactly these elements. They connect carrier to carrier, to a Bus Selector, or from a Bus Creator. A bus into a generic block stays the bus-into-block wiring problem: generic blocks work on channels.
    3. Expansion before code generation resolves a carrier port to its channel indices, so the generated connections stay index-based. TS and Python kept in agreement through bus_expansion.json.
  2. milanofthe commented on Nov 10, 2026

    @milanofthe
    MemberAuthor

    Revised plan, replaces the one above:

    1. Introspection reports a carrier port as one port whose channels are a bus structure (BusStructure, the representation the bus analysis already uses): one plain element per key, positions 0..n-1 for a Vector. No channel layout (start) in PathView; the register layout stays with pathsim. (Read carrier port labels as bus ports in block introspection #350)
    2. Code generation addresses labeled ports by name (heater["stream"], amp["in"]), variable ports stay by index. Port position and channel index only coincide while every label is a single, contiguous channel, which a carrier breaks. Applies to the code builder, the live mutation queue and converter.py.
    3. Carrier ports are bus ports in the bus analysis and expansion: a carrier output is a bus source, a carrier input takes a bus with the same elements. A single channel after expansion is addressed by port and key (heater["stream"]["T"]). A bus into a generic block stays bus-into-block. TS and Python kept in agreement through bus_expansion.json.
  3. milanofthe commented on Nov 10, 2026

    @milanofthe
    MemberAuthor

    Done in #350 (carrier ports introspected as bus structures), #351 (labeled ports addressed by label in generated code) and #352 (carrier ports as bus ports in the bus analysis and expansion). Note for the next release: generated scripts now address labeled ports by label, e.g. pt1["in"] instead of pt1[0].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions