Skip to content
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

ref(seer grouping): SeerSimilarIssueData.from_raw improvements #70668

Merged
merged 6 commits into from May 14, 2024

Conversation

lobsterkatie
Copy link
Member

@lobsterkatie lobsterkatie commented May 10, 2024

This makes a number of improvements to the from_raw1 factory method in the SeerSimilarIssueData` dataclass, all related to the fact that the data being fed to it comes straight from the JSON returned by Seer and so we can't actually guarantee what's in it.

Included changes:

  • Loosen the typing of the raw_similar_issue_data parameter, from RawSeerSimilarIssueData (implying we know exactly what's in it) to Mapping[str, Any] (acknowledging that we don't).
  • Add check to ensure all required keys are present.
  • Filter out any data with unknown keys, to prevent the SeerSimilarIssueData constructor from crashing with an 'unknown keyword argument' error in the case of unexpected data.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label May 10, 2024
@lobsterkatie lobsterkatie marked this pull request as ready for review May 10, 2024 18:42
@lobsterkatie lobsterkatie force-pushed the kmclb-add-dictionary-filter-helper branch from f1cf889 to 05955be Compare May 14, 2024 05:06
@lobsterkatie lobsterkatie force-pushed the kmclb-seer-data-from_raw-improvements branch from db22d42 to 3d4e03a Compare May 14, 2024 05:07
Comment on lines 148 to 150
required_keys = {"stacktrace_distance", "message_distance", "should_group"}
optional_keys = {"parent_hash", "parent_group_id"}
expected_keys = {*required_keys, *optional_keys}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: since these are constants, you could pull them out of the function to be on the class / a constant at top of file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Done.

Base automatically changed from kmclb-add-dictionary-filter-helper to master May 14, 2024 21:12
Copy link

codecov bot commented May 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.03%. Comparing base (3261de0) to head (33cd705).
Report is 5 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #70668   +/-   ##
=======================================
  Coverage   80.02%   80.03%           
=======================================
  Files        6508     6508           
  Lines      291198   291270   +72     
  Branches    50202    50200    -2     
=======================================
+ Hits       233028   233104   +76     
+ Misses      57736    57732    -4     
  Partials      434      434           
Files Coverage Δ
src/sentry/seer/utils.py 99.28% <100.00%> (+0.04%) ⬆️

... and 15 files with indirect coverage changes

@lobsterkatie lobsterkatie merged commit 57a2f28 into master May 14, 2024
50 checks passed
@lobsterkatie lobsterkatie deleted the kmclb-seer-data-from_raw-improvements branch May 14, 2024 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants