You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The functionality from https://github.com/jagill/python-chainz#errors would be useful for certain use cases. Wrapping this into Lineage seems like a fairly clean way to accomplish this.
On a side note, this might be a good time to look at making the exceptions raised from evaluating an incorrect user function in a PyFunctional pipeline cleaner. Currently, there is quite a bit of noise when its is very unlikely the core issue is coming from PyFunctional.
The text was updated successfully, but these errors were encountered:
In order to handle this, its not enough to wrap the code that executes the sequence, it will still error out. In order to catch that exception you either need to catch it where next is called, wrap f when it is passed through to map, or use a yield statement like done here https://github.com/jagill/python-chainz/blob/master/chainz/chain.py#L52
The first one is obviously not an option since thats user code vs library code. There are two possible problematic implementations:
You could wrap f then pass it through. The issue is that there would need to be checks on all methods that accept a function if on_error would work as expected. This is a lot of methods that would have to be changed to support this single one which I don't think adds much value (more on this later)
The second one is clear how to do for map and other functions that operate at a single "level". For example, flat_map since tricky since the results have to get concatenated. The generalization is that implementing this would be method specific so quite a bit of work.
Lastly, I don't think it brings much value for all the effort needed. It would be much easier for user code to handle the exception explicitly. This could be easy to do using flat_map very easily. If there is an error output an empty list, otherwise a tuple of one element (yay monads). It would also be easy to do a map then filter.
I had hoped the implementation wouldn't require so much code change and would be easy, but wasn't to be. I am open to other ideas, but closing issue for now.
The functionality from https://github.com/jagill/python-chainz#errors would be useful for certain use cases. Wrapping this into
Lineage
seems like a fairly clean way to accomplish this.On a side note, this might be a good time to look at making the exceptions raised from evaluating an incorrect user function in a
PyFunctional
pipeline cleaner. Currently, there is quite a bit of noise when its is very unlikely the core issue is coming fromPyFunctional
.The text was updated successfully, but these errors were encountered: