Move mappings into main package and load via importlib.resources #47
Merged
Conversation
Moves the five mapping config YAMLs from the separate isp_trace_name_mapping_configs top-level package into src/isp_trace_parser/mappings/, and updates the trace modules to load them from the new location
Adds a central mappings.load() function that loads the yaml configs through importlib.resources (replaces the open()/Path/yaml.safe_load blocks in the solar, wind, and demand trace modules with single function calls). Centralises the package-data lookup (should help with future development / evolution package / mappings).
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
nick-gorman
approved these changes
Apr 22, 2026
Member
nick-gorman
left a comment
There was a problem hiding this comment.
Looks good Dylan, definitely how we should have done it to begin with!
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.
Hopefully moderately straight forward / easy change that addresses #35 - main changes:
isp_trace_name_mapping_configstop-level package intosrc/isp_trace_parser/mappings/, so package data lives inside the main package rather than a sibling one.Path(__file__).parent.parent / "isp_trace_name_mapping_configs/..."functions with a simplemappings.load()helper function (that usesimportlib.resources) - which I think it more standard way to access bundled package data (and behaves consistently across install layouts editable, wheel, zipped, etc).solar_traces.py,wind_traces.py,demand_traces.py) load yamls via a singlemappings.load("<name>")call instead of repeating the open/Path/yaml-parse pattern/approach.Think #14 obsolete now too - that issue was partly about cleaning up how the mapping data is laid out / referenced, which this change relates to.
(..this change should make updates to 2026 mappings a little easier / neater)