Processor Modules
Processor modules are the most flexible modules compared to input and output modules because they have an input and output port. Processor modules can be used to manipulate (e.g., filter) incoming data objects or apply custom algorithms.
Example
from modules.base.processors.base import AbstractProcessorModule, models
class ProcessorModule(AbstractProcessorModule):
...
def __init__(self, configuration: Configuration):
super().__init__(configuration=configuration, thread_safe=False)
self.count: int = 0
def _run(self, data: models.Data) -> models.Data:
"""
Method for executing the module.
:param data: The data object.
:returns: The data object after processing.
"""
self.count += 1
data.fields["data_object_count"] = self.count
return data
Info
The
_run
method is called by a single thread and is therefore thread-safe if enabled: thread_safe=True