GreaterThan, LLC

Events All The Way Down

First things first: It’s been a little over a month since the first version of PipeLayer was published and to celebrate, it got a shiny new logo!

Events that were added to the Filter abstract class have been extended to the Pipeline and Switch by inheriting from the Filter abstract class. With the addition of these events, the pre/post process methods in the Filter class became somewhat redundant—removing them streamlined the pipeline runner.

from pipelayer import Filter, FilterEventArgs, Pipeline


class MyStep(Filter):
    def run(self, data = None, context = None):
        ...

def my_pipeline_start(o: Pipeline, e: FilterEventArgs):
    ...

my_pipeline = Pipeline([MyStep])
my_pipeline.start += my_pipeline_start

output = my_pipeline.run()

Also, you may have noticed the assignment operator used to add event handlers. This was added in v0.5.1. Now handlers can be added in a variety of ways:

my_filter.exit += my_event_handler
my_filter.exit.append(my_event_handler)
my_filter.exit = my_filter.exit + my_event_handler

in PipeLayer, PyPi, Python