IOChain
- class ioiocore.io_chain.IOChain(input_ports=None, output_ports=None, **kwargs)[source]
Bases:
ChainA chain with both input and output ports, processing data through a sequence of internal nodes.
Structure: IONode => IONode => … => IONode
Input ports are exposed from the first internal node, and output ports are exposed from the last internal node, making this chain usable anywhere an IONode-like element is expected.
Inheriting classes must implement
create_internal_nodes(), which returns the list of internal nodes.Example
class MyProcessor(IOChain): def create_internal_nodes(self) -> List[Node]: return [ PreFilterNode(), # IONode (input exposed) TransformNode(), # IONode PostFilterNode() # IONode (output exposed) ]
- Parameters:
input_ports (list)
output_ports (list)
- class Configuration(input_ports=None, output_ports=None, **kwargs)[source]
Bases:
ConfigurationConfiguration class for IOChain.
- Parameters:
input_ports (list)
output_ports (list)
- class Keys[source]
Bases:
KeysKeys for the IOChain configuration.
- INPUT_PORTS = 'input_ports'
- OUTPUT_PORTS = 'output_ports'
- __init__(input_ports=None, output_ports=None, **kwargs)[source]
Initialize the IOChain configuration.
- Parameters:
input_ports (
list) – A list of input port configurations. If None, ports will be inherited from the first internal node.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__(input_ports=None, output_ports=None, **kwargs)[source]
Initialize the IOChain.
- Parameters:
input_ports (
list) – A list of input port configurations (default is None).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.
All nodes must be IONodes (have both input and output ports).
- Returns:
List of internal IONodes 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_input_port(port_name)[source]
Get an input port by name from the first internal node.
- Parameters:
port_name (str)
- get_output_port(port_name)[source]
Get an output port by name from the last internal node.
- Parameters:
port_name (str)
- get_port(port_name)[source]
Deprecated: use
get_input_port()instead.- Parameters:
port_name (str)