-
-
Notifications
You must be signed in to change notification settings - Fork 293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add "Defer errors" option to applicable iterators #2442
Conversation
Instead of dealing with deferred errors in one place (where you actually do the iterating), you now handle it separately in 4 places. Iterator progress is also messed up because errors silently caught by the iterator itself can't be accounted for (the issue is that Yeah, I'm not a fan of this. Could we do the |
sure |
Doesn't work. I reverted the stuff in api.py back aside from setting Since I know you'll wanna test it yourself, I pushed my changes to a new branch called |
That's my bad. def supplier():
for i, x in enumerate(l):
yield map_fn(x, i) Obviously the generator will stop when So I read through python's docs, and it just doesn't tell you what will happen when the So I guess the only solution compatible with python would be to roll our own So we need to change our API to Also, first thing I noticed: iterable = iterator_output.iterator.iter_supplier()
while True:
try:
values = next(iterable) # type: ignore This is wrong and the type error even told you that. So why did your previous code seem to work anyway? Luck. Under the hood, we use python generator functions ( Here's what it needs to be: iterator = iter(iterator_output.iterator.iter_supplier())
while True:
try:
values = next(iterator) |
I did try that but I got rid of it because it wasn't doing anything (as in, it didn't fix my problem) |
Also, I really don't want to implement a whole result system and make all those changes right now. That's something I actually started doing back when I first tried this and it was gonna be a lot of work. Can we just use what this branch does for now? Even if it's not ideal? |
Checkout the
Sorry, I put this in a confusing way. Yes, this doesn't fix your problem. It's just also wrong. |
Thanks :) that's a pretty elegant solution. Just merged that into this branch |
So it turns out the reason it wasn't working properly before was because of #2440... The models i was using just weren't being picked up by the node i was using to test. Therefore, I didn't actually need to do the manual iteration with the
while True
+next()
nonsense.This might not be the most glamorous solution, but it works and I'm happy enough with it.