component
Component submodule providing functionality related to components and their execution.
Component
Component(
*,
name: str,
initial_values: Optional[dict[str, Iterable]] = None,
parameters: Optional[dict[str, Any]] = None,
state: Optional[StateBackend] = None,
constraints: Optional[dict] = None,
)
Bases: ABC, ExportMixin
Component base class for all components in a process model.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
The name of the component. |
|
io |
IOController
|
The |
exports |
Optional[list[str]]
|
Optional; The exportable fields from the component during distributed runs in addition to input and output fields. |
__setattr__
Sets attributes on the component.
If the attribute is an input field, it is set in the field input buffer for the current
step. This data is consumed by the step method when it is called and must be reset for
subsequent steps.
connect_state
async
Connects the Component to the StateBackend.
IOController
IOController(
inputs: Optional[Any] = None,
outputs: Optional[Any] = None,
initial_values: Optional[dict[str, Iterable]] = None,
input_events: Optional[list[Type[Event]]] = None,
output_events: Optional[list[Type[Event]]] = None,
namespace: str = IO_NS_UNSET,
component: Optional[Component] = None,
)
IOController manages input/output to/from components.
connect
async
Connects the input/output fields to input/output channels.
read
async
Reads data and/or events from input channels.
Read behaviour is dependent on the specific combination of input fields, output fields,
and input events. In general, all components will have at a minimum the system defined
input events, such as StopEvent. Logic for the various cases is as follows:
- At least one input field: the method waits until either all input fields have received data or an input event is received, and returns after whichever occurs first.
- No input fields but at least one output field: the method waits for a short amount of time to give chance for input events to be received before returning so that the control flow can continue on to processing output events.
- No input fields or output fields: this is the pure event driven case where the method waits until an input event is received, and returns after the first received event.
component.utils
Provides utility functions for working with Plugboard components.
ComponentDecoratorHelper
Stores wrapped function and dynamically created component class.
component
component(
inputs: Optional[Any] = None,
outputs: Optional[Any] = None,
) -> _t.Callable[[_FuncT], "ComponentDecoratorHelper"]
A decorator to auto generate a Plugboard component from a function.
The wrapped function will be added to a dynamically created component class as the step method. The returned helper class can either be called directly, retaining the original behaviour of the wrapped function; or can be used to create a component instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inputs
|
Optional[Any]
|
The input schema or schema factory for the component. |
None
|
outputs
|
Optional[Any]
|
The output schema or schema factory for the component. |
None
|
Returns:
| Type | Description |
|---|---|
Callable[[_FuncT], 'ComponentDecoratorHelper']
|
A helper class which can be used to both call the original function and create |
Callable[[_FuncT], 'ComponentDecoratorHelper']
|
an instance of the component class. |