results: Bail out gracefully when profile data is missing - #1614
Open
chiruu12 wants to merge 1 commit into
Open
Conversation
get_profile indexed _profiles directly and called encode on the result, so a benchmark with no stored profile raised KeyError, and one stored as None raised AttributeError. add_result only writes the entry when the profile is truthy, so both shapes are reachable. It now raises UserError, which main.py already turns into a logged error rather than a traceback. Also corrects the docstring, which promised pstats.Stats but returns raw bytes. get_profile_stats has been the Stats-returning method since airspeed-velocity#1253.
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.
Closes #1459.
get_profileindexed_profilesdirectly and then called.encode()on the result, so a benchmark with no stored profile raisedKeyError, and one stored asNoneraisedAttributeError.add_resultonly writes the entry when the profile is truthy, so both shapes are reachable.It now raises
UserError, whichmain.pyalready turns into a logged error and a non-zero exit rather than a traceback. Of the three call sites, two guard withhas_profilefirst, and the third isasv profileright after a profiling run, which is the one that surfaced this.Also corrects the docstring, which promised
pstats.Statsbut returns raw bytes.get_profile_statshas been the Stats-returning method since #1253.Added a test covering both shapes. It fails on main with
KeyErrorand passes here.pytest test/test_profile.py test/test_results.pypasses, 11 tests.pre-commit run --filespasses on all changed files.