Add bug_map as a cached property for LandingsRiskReportGenerator#6268
Open
Karthikvenugopal wants to merge 1 commit into
Open
Add bug_map as a cached property for LandingsRiskReportGenerator#6268Karthikvenugopal wants to merge 1 commit into
Karthikvenugopal wants to merge 1 commit into
Conversation
bug_map was built as a local dict inside go() and threaded through get_blocking_of, generate_landings_by_date, generate_component_connections, and generate_component_test_stats as an explicit parameter. Turn it into a @cached_property so it no longer has to be passed around. Because bug_map is filtered against bugs_set, which is derived from the bugs, test_info_bugs, and meta_bugs locals computed in go(), those locals are now promoted to instance attributes (self.bugs, self.test_info_bugs, self.meta_bugs), set in go() before bug_map is first accessed. The property can then rebuild bugs_set and compute bug_map from self alone, preserving the existing filtering (bugs we are interested in, bugs blocked by other bugs, and bugs that caused regressions). Fixes mozilla#5053
Author
|
Hi @suhaibmujahid, this PR implements the |
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
Implements the follow-up from #5053:
bug_mapis now a@cached_propertyonLandingsRiskReportGeneratorinstead of a local dict ingo()passed as anexplicit argument to every method that needs it.
Changes
from functools import cached_property.bug_mapcached property reproducing the existing filtering (keep bugswe are interested in, bugs blocked by other bugs, and bugs that caused
regressions).
bugs,test_info_bugs,meta_bugs) to instance attributes set ingo()beforebug_mapis firstaccessed.
bug_mapparameter fromget_blocking_of,generate_landings_by_date,generate_component_connections, andgenerate_component_test_stats, and update their bodies and the call sites ingo()to useself.bug_map.Why the dependencies had to move too
bug_mapis filtered againstbugs_set, which is derived from thebugs,test_info_bugs, andmeta_bugslocals computed earlier ingo(). Acached_propertyonly receivesself, so those inputs had to live on theinstance for the property to rebuild the same set. They are assigned in
go()before any consumer touches
self.bug_map.Notes
bug_map, so sharing a single cached dict across consumersis safe.
go()runs once per process, sokeeping these values on the instance does not change the effective memory
lifetime.
Testing
pre-commit run --all-filespasses (ruff, ruff-format, mypy, codespell, etc.).Fixes #5053