ProcessingElement

class ioiocore.processing_element.ProcessingElement(**kwargs)[source]

Bases: ABC, Portable

Abstract base class for all processing elements in a pipeline.

This is the common base for both Node (concrete processing nodes) and Chain (containers of nodes). It provides the shared interface that Pipeline uses to manage elements.

_IMP_CLASS

The implementation class for the ProcessingElement.

Type:

type

_imp

The instance of the implementation class.

Type:

_IMP_CLASS

config

The configuration object for the ProcessingElement.

Type:

Configuration

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

Bases: Configuration

Configuration class for the ProcessingElement.

Parameters:

name (str)

Keys[source]

The configuration keys.

class Keys[source]

Bases: Keys

Configuration keys.

NAME = 'name'
__init__(name=None, **kwargs)[source]

Initialize the ProcessingElement configuration.

Parameters:
  • name (str) – The name of the ProcessingElement (default is the class name).

  • kwargs (additional keyword arguments) – Other configuration parameters passed to the base class.

config: Configuration
create_config(**kwargs)[source]

Factory method to create the configuration for the ProcessingElement.

Sets name to the interface class name if not provided. This ensures that concrete subclasses that don’t define their own Configuration class still get the correct name (e.g., a concrete OChain subclass will be named after itself, not “OChain”).

Parameters:

**kwargs – Additional keyword arguments for configuring the ProcessingElement.

failure()[source]

The exception this element raised, kept whole.

Returns:

What setup() or a cycle raised, or None if nothing did.

Reported alongside the log entry rather than instead of it, because the two serve different readers. The log is what a running system writes down; this is what a caller needs to raise from, so the element’s own frames end up in front of the user instead of a sentence quoting them.

The first failure is kept. A node that fails during setup returns from every later cycle without processing, and the condition it leaves behind makes the next cycle look like a fresh failure – so overwriting would replace the cause with its consequence.

Return type:

Exception

get_condition()[source]

Get the current condition.

Returns:

HEALTHY, WARNING or ERROR. An element sets ERROR on itself when its setup or its step raises, and only reset_run_state() clears it again.

Return type:

Conditions

get_context()[source]

Get the context of this processing element.

Return type:

Context

get_counter()[source]

Get the current counter value.

Returns:

The counter value.

Return type:

int

get_state()[source]

Get the current state.

Returns:

The current state.

Return type:

States

log(msg, type=None)[source]

Write a log message.

Parameters:
property name: str

Get the name of this processing element.

set_logger(logger)[source]

Set the logger for this processing element.

Parameters:

logger (Logger)

setup_failed()[source]

Whether setup() raised, as opposed to a later cycle.

Returns:

True if this element’s setup() raised. Reported apart from the condition because the two mean different things to a caller: a step that raises is a run that died, while a setup that raises is an element that was never viable – which the start() the caller is still inside can still refuse.

Return type:

bool

abstractmethod start()[source]

Start the processing element.

abstractmethod stop()[source]

Stop the processing element.