PipeLayer 0.5.0
This release introduces Filter Events, and Pipeline Actions.
These events are raised by the Filter object:
start
exit
end
They can be handled by attaching a callable to each event. The start and end events are raised automatically, but the exit event is triggered by setting the action
in the event handler to either EXIT
, or SKIP
.
Like this:
from pipelayer import Filter, FilterEventArgs, Pipeline, Action
from pipelayer.filter import raise_events
class MyFilter(Filter):
@raise_events # Raises the events
def run(self, data, context):
return f"{data}has been changed"
# Handles the filter start event
def my_filter_start(obj: Filter, args: FilterEventArgs):
args.data = "Filter Skipped"
args.action = Action.SKIP # This will skip over the step
my_filter = MyFilter()
my_filter.start.append(my_filter_start)
my_pipeline = Pipeline(steps=[
my_filter
])
output = my_pipeline.run("Some data...", None)
# output is "Filter Skipped"