[DataStore] fix bare except clause in openai_provider async batch invoke - #9861
Open
qubeena07 wants to merge 1 commit into
Open
[DataStore] fix bare except clause in openai_provider async batch invoke#9861qubeena07 wants to merge 1 commit into
qubeena07 wants to merge 1 commit into
Conversation
Using a bare except clause catches BaseException implicitly which is a Python anti-pattern flagged by Ruff E722. The intent here is to cancel sibling tasks on any failure including asyncio.CancelledError which is a BaseException subclass in Python 3.8 and above. Changed to explicit except BaseException to preserve the same behavior while making the intent clear. Fixes mlrun#9860 Co-Authored-By: Dipika Ranabhat <qubeena7@gmail.com>
2 tasks
liranbg
approved these changes
Jun 22, 2026
liranbg
left a comment
Member
There was a problem hiding this comment.
Thank you for your first contribution @qubeena07! :)
Contributor
|
Smoke Tests with the PR synced to |
Contributor
📊 Diff Coverage Report📂 Click to view full coverage detailsDiff CoverageDiff: origin/development...HEAD, staged and unstaged changes
Summary
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #9860
In
mlrun/datastore/model_provider/openai_provider.pythe async batch invoke method used a bareexcept:clause to catch exceptions duringasyncio.gather()so it could cancel sibling tasks before re-raising.A bare
except:is a Python anti-pattern (Ruff E722) because it catchesBaseExceptionimplicitly, making the intent of the code unclear. More importantly, in Python 3.8 and aboveasyncio.CancelledErroris a subclass ofBaseExceptionnotException, so changing toexcept Exception:would silently break the cancellation cleanup path.The correct fix is
except BaseException:which is explicit, preserves exactly the same behavior, and satisfies Ruff E722.Changes:
mlrun/datastore/model_provider/openai_provider.pyfrom bareexcept:toexcept BaseException:Test plan