Would there be interest in a `FilterTask` variant ...
# ask-community
s
Would there be interest in a
FilterTask
variant that had an extra parameter along the lines of:
Copy code
log_filtered (Callable, optional): a function to use for logging any result that did not pass `filter_func`.
Use would be something like:
Copy code
valid_configurations = FilterTask(filter_func=some_validator, log_filtered=log_invalid_configuration)
where
Copy code
def log_invalid_configuration(configuration):
    # log the reasons this configuration is invalid. Or some other special logging for invalid configurations.
    # Like, notifying a team to fix the configuration.
Adding this to
FilterTask
would be straightforward. Turn the list comprehension info a for loop appending to
filtered
and call
log_filtered
whenever a result does not match the predicate. I am currently making 2 calls to FilterTask, once to collect valid and once to collect invalid. Which is not pretty.
z
Hey @Sean Perry -- that's a wonderful idea. So wonderful that I had it recently as well 😄 This is something that we'll be looking into on our roadmap so we probably won't accept a user-contribution for it but I'm happy to chat about it more if you'd like!
s
All good. I can add a custom Task type to our code and transition when you release it.