fix: Fixed logic error in index_tweak_folder which resulted in parsing all tweaks twice#15
Merged
Merged
Conversation
Logic error in the previous implementation resulted in all tweaks being read and parsed multiple times. - Replaced recursive logic in index_tweak_folder with using Path.rglob -function. - Function index_tweak_folder now returns the tweak name (in pattern layer.name) and path to the tweak. Tweaks with duplicate names can be dropped before parsing the JSON. - Separated reading and parsing of the JSON-files to separate parse_tweak -function. This makes it easier to use multiprocessing for parsing the JSONs if necessary. - get_tweak -function now parses only the requested tweak instead of all tweaks. - Added basic logging.
Owner
|
Thanks for the fix! |
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.
Description
The implementation of rejecting same tweaks in index_tweak_folder only considered duplicates inside the same folder,
not possible duplicates from other previously indexed folders. Since the tweak layer and name are constructed from the folder structure and filename, and no known OS filesystem allows two identical filenames in same folder, this resulted in dead code.
The rejection of duplicates only happened after the files had been already read and parsed, which created double the amount of calls to the JSON-parser which is quite slow in python.
Fixes:
With the above changes
cProfile.run("get_tweaks()")went fromto
and
cProfile.run("get_tweak('themes.reset')")fromto
API-changes:
dict[str, TweakData]todict[str, Path]. Only called internally in tweaks.py.set[str]todict[str, Path]. All code calling get_tweak_names is ok with this.Type of Change
feat:New featurefix:Bug fixdocs:Documentation updatetweak:New tweak filetest:Test additions/changeschore:Build/tooling changesChecklist