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

Show JSON schema
{
   "title": "Gather",
   "description": "Cardinality reduction.\n\nGiven a node that emits >1 events, gather them into a single iterable.\n\nTwo (mutually exclusive) modes:\n\n- gather a fixed number of events\n\n.. code-block:: yaml\n\n    nodename:\n      type: gather\n      params:\n        n: 5\n      depends:\n        - value: othernode.signal\n\n- gather events until a trigger is received\n\n.. code-block:: yaml\n\n    nodename:\n      type: gather\n      depends:\n        - value: othernode.signal_1\n        - trigger: thirdnode.signal_2",
   "type": "object",
   "properties": {
      "id": {
         "title": "Id",
         "type": "string"
      },
      "spec": {
         "anyOf": [
            {
               "$ref": "#/$defs/NodeSpecification"
            },
            {
               "type": "null"
            }
         ],
         "default": null
      },
      "enabled": {
         "default": true,
         "title": "Enabled",
         "type": "boolean"
      },
      "stateful": {
         "default": true,
         "title": "Stateful",
         "type": "boolean"
      },
      "n": {
         "anyOf": [
            {
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "N"
      }
   },
   "$defs": {
      "NodeSpecification": {
         "description": "Specification for a single processing node within a tube .yaml file.",
         "properties": {
            "type": {
               "title": "Type",
               "type": "string"
            },
            "id": {
               "title": "Id",
               "type": "string"
            },
            "depends": {
               "anyOf": [
                  {
                     "items": {
                        "anyOf": [
                           {
                              "type": "string"
                           },
                           {
                              "additionalProperties": {
                                 "type": "string"
                              },
                              "maxProperties": 1,
                              "minProperties": 1,
                              "type": "object"
                           }
                        ]
                     },
                     "type": "array"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Depends"
            },
            "params": {
               "anyOf": [
                  {
                     "additionalProperties": true,
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Params"
            },
            "enabled": {
               "default": true,
               "title": "Enabled",
               "type": "boolean"
            },
            "stateful": {
               "anyOf": [
                  {
                     "type": "boolean"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Stateful"
            },
            "description": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Description"
            }
         },
         "required": [
            "type",
            "id"
         ],
         "title": "NodeSpecification",
         "type": "object"
      }
   },
   "additionalProperties": false,
   "required": [
      "id"
   ]
}

Config:
  • extra: str = forbid

Fields:
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, trigger: Any | None = None) list[_TInput] | MetaSignal[source]

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