datahq / dataflows

DataFlows is a simple, intuitive lightweight framework for building data processing flows in python.
https://dataflows.org
MIT License
193 stars 39 forks source link

Adds noop processor. #166

Closed pwalsh closed 2 years ago

pwalsh commented 2 years ago

Useful for composing flows as parameterized higher order functions.

Simple example:

import data flows as DF

my_data = [...]

def my_great_flow(validate=False):
    return DF.Flow(
        my_data,
        DF.validate() if validate is True else DF.noop()            
    )

An alternative approach would be to allow None values in the processor list passed to a flow (... else None rather than ... else DF.noop()), and then filter the list for Nones before running the processors. I don't have a personal preference but perhaps exposing a noop processor is the more explicit approach for consumers of the library.

akariv commented 2 years ago

Hey @pwalsh, you can actually use None instead of the noop and it will work as intended.

On Fri, Sep 17, 2021, 10:44 Paul Walsh @.***> wrote:

Useful for composing flows as parameterized higher order functions.

Simple example:

import data flows as DF

my_data = [...]

def my_great_flow(validate=False): return DF.Flow( my_data, DF.validate() if validate is True else DF.noop() )

An alternative approach would be to allow None values in the processor list passed to a flow (... else None rather than ... else DF.noop()), and then filter the list for Nones before running the processors. I don't have a personal preference but perhaps exposing a noop processor is the more explicit approach for consumers of the library.

You can view, comment on, or merge this pull request online at:

https://github.com/datahq/dataflows/pull/166 Commit Summary

  • Adds noop processor.

File Changes

Patch Links:

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/datahq/dataflows/pull/166, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACAY5ISNZBI2FCFD2RIAZLUCL5WRANCNFSM5EGQNJCQ .

pwalsh commented 2 years ago

:). Don't know how I missed that.

akariv commented 2 years ago

Just a testament to the quality of my documentation I guess 😇

On Fri, Sep 17, 2021, 13:11 Paul Walsh @.***> wrote:

Closed #166 https://github.com/datahq/dataflows/pull/166.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/datahq/dataflows/pull/166#event-5318684814, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACAY5P5FVYUAG3S6TMPE6DUCMO4NANCNFSM5EGQNJCQ .

pwalsh commented 2 years ago

@akariv no, in this case I think early on I had a failing Flow, and thought it was a None processor, so I wrote a noop and moved on, and just kept using it. I never went back to check thoroughly.