gather

pydantic model Gather[source]

Cardinality reduction.

Given a node that emits >1 events, gather them into a single iterable.

Two (mutually exclusive) modes:

  • gather a fixed number of events

nodename:
  type: gather
  params:
    n: 5
  depends:
    - value: othernode.signal
  • gather events until a trigger is received

nodename:
  type: gather
  depends:
    - value: othernode.signal_1
    - trigger: thirdnode.signal_2
Config:
  • extra: str = forbid

Fields:
field flatten: bool = False

If an individual gathered value is a sequence (and thus the returned gathered value a sequence of sequences), flatten the sequences by 1 level.

[[‘a’, ‘b’], [‘c’], []] -> [‘a’, ‘b’, ‘c’]

field n: int | None = None
model_post_init(_Node__context: Any) None

See docstring of process() for description of post init wrapping of generators

process(value: _TInput, epoch: Epoch, trigger: Any | None = None, n: int | None = None) Event[list[_TInput]] | MetaSignal[source]

Collect value in a list, emit if n is met or trigger is present