Repository navigation
FIX Each callback context should be closed exactly once - #35447
Conversation
lorentzenchr
left a comment
There was a problem hiding this comment.
Thanks @betatim for the quick follow-up.
|
@betatim Could you resolve merge conflicts? Then I‘ll merge. |
|
@copilot resolve the merge conflicts in this pull request (what could possibly go wrong 🙄) Edit: nothing went wrong because Copilot didn't do anything apparently ... |
…ck-ctx # Conflicts: # sklearn/linear_model/_logistic.py
|
I didn't notice there were conflicts :( Having a (sufficiently powerful) bot that can resolve conflicts would be useful. Then a reviewer can trigger it, take a look and merge or throw it back to the PR author if it looks like it needs human attention to get the resolution right. Reminds me a bit of the "auto merge" button which I at first thought was gimmicky but turns out to be super useful because you can say "merge, assuming all the tests pass". Which means the PR is "done" for you instead of leaving an open loop |
Reference Issues/PRs
Follow up to #35334
What does this implement/fix? Explain your changes.
This fixes the problem
If I run this locally on main I indeed see two ends for the same context:
The first
lbfgs-iterend comes from __call__, just before it raisesStopIteration. The second comes fromclose(), which assumes_iter_ctxis always a fresh context that hasn't run yet. That stops being true once the fit is stopped. A minimal fix is to setself._iter_ctx = Nonebefore raising, and haveclose()return early when it'sNone.The begin/end count assertion would also be worth adding to
test_logistic_regression_fit_stopped_by_callback.AI usage disclosure
I used AI assistance for:
cc @lorentzenchr @jeremiedbb @lesteve