timeflux_example.nodes.dynamic module

Illustrates dynamic inputs and outputs.

class timeflux_example.nodes.dynamic.Outputs(prefix=None, seed=None)[source]

Bases: timeflux.core.node.Node

Randomly generate dynamic outputs.

At each update, this node generates a random number of outputs and sets the default output to the number it has created.

Variables
  • o (Port) – Default output, provides DataFrame.

  • o_* (Port) – Dynamic outputs.

Parameters
  • seed (int) – The random number generator seed.

  • prefix (string) – The prefix to add to each dynamic output.

Example

graphs:

  - id: DynamicIO

    nodes:
    - id: node_1
      module: timeflux_example.nodes.dynamic
      class: Outputs
      params:
        seed: 1
        prefix: foo
    - id: node_2
      module: timeflux_example.nodes.dynamic
      class: Inputs
      params:
        prefix: bar
    - id: node_3
      module: timeflux.nodes.debug
      class: Display
    - id: node_4
      module: timeflux.nodes.debug
      class: Display

    edges:
    - source: node_1:foo_* # Dynamic inputs can be prefixed
      target: node_2:bar   # The same goes for outputs
    - source: node_1
      target: node_3
    - source: node_2
      target: node_4
__init__(prefix=None, seed=None)[source]

Instantiate the node.

update()[source]

Update the input and output ports.

class timeflux_example.nodes.dynamic.Inputs(prefix=None)[source]

Bases: timeflux.core.node.Node

Count the dynamic outputs.

At each update, this node loops over all dynamic inputs and sets the default output to the number it has found.

Variables
  • i_* (Port) – Dynamic inputs.

  • o (Port) – Default output, provides DataFrame.

Parameters

prefix (string) – The prefix to add to match dynamic inputs.

Example

graphs:

  - id: DynamicIO

    nodes:
    - id: node_1
      module: timeflux_example.nodes.dynamic
      class: Outputs
      params:
        seed: 1
    - id: node_2
      module: timeflux_example.nodes.dynamic
      class: Inputs
    - id: node_3
      module: timeflux.nodes.debug
      class: Display
    - id: node_4
      module: timeflux.nodes.debug
      class: Display

    edges:
    - source: node_1:* # The magic happens here
      target: node_2
    - source: node_1
      target: node_3
    - source: node_2
      target: node_4
__init__(prefix=None)[source]

Instantiate the node.

update()[source]

Update the input and output ports.