OChain

class ioiocore.o_chain.OChain(output_ports=None, **kwargs)[source]

Bases: Chain

A chain that generates output through a sequence of internal nodes.

Structure: ONode => IONode => … => IONode => <output>

The output ports are exposed from the last internal node, making this chain usable anywhere an output element is expected.

Inheriting classes must implement create_internal_nodes(), which returns the list of internal nodes.

Example

class MyGenerator(OChain):
    def create_internal_nodes(self) -> List[Node]:
        return [
            SourceNode(),    # ONode (generator)
            FilterNode(),    # IONode
            TransformNode()  # IONode (output exposed)
        ]
Parameters:

output_ports (list)

class Configuration(output_ports=None, **kwargs)[source]

Bases: Configuration

Configuration class for OChain.

Parameters:

output_ports (list)

class Keys[source]

Bases: Keys

Keys for the OChain configuration.

OUTPUT_PORTS = 'output_ports'
__init__(output_ports=None, **kwargs)[source]

Initialize the OChain configuration.

Parameters:
  • output_ports (list) – A list of output port configurations. If None, ports will be inherited from the last internal node.

  • **kwargs (additional keyword arguments) – Other configuration options.

__init__(output_ports=None, **kwargs)[source]

Initialize the OChain.

Parameters:
  • output_ports (list) – A list of output port configurations (default is None).

  • **kwargs (additional keyword arguments) – Other configuration options.

config: Configuration
connect(output_port, target, input_port)[source]

Connect an output port to an input port of a target node.

Parameters:
  • output_port (str) – The name of the output port on this chain.

  • target (INode) – The target node to connect to.

  • input_port (str) – The name of the input port on the target node.

abstractmethod create_internal_nodes()[source]

Create and return the list of internal nodes.

The first node must be an ONode. The last node must have output ports (ONode or IONode). Intermediate nodes should be IONodes.

Returns:

List of internal nodes forming the processing chain.

Return type:

List[Node]

disconnect(output_port, target, input_port)[source]

Disconnect an output port from an input port of a target node.

Parameters:
  • output_port (str) – The name of the output port on this chain.

  • target (INode) – The target node to disconnect from.

  • input_port (str) – The name of the input port on the target node.

get_output_port(port_name)[source]

Get an output port by name.

Parameters:

port_name (str)

get_port(port_name)[source]

Deprecated: use get_output_port() instead.

Parameters:

port_name (str)