Skip to content

Move mappings into main package and load via importlib.resources #47

Merged
dylanjmcconnell merged 2 commits into
mainfrom
package-data-update
Apr 22, 2026
Merged

Move mappings into main package and load via importlib.resources #47
dylanjmcconnell merged 2 commits into
mainfrom
package-data-update

Conversation

@dylanjmcconnell
Copy link
Copy Markdown
Member

Hopefully moderately straight forward / easy change that addresses #35 - main changes:

  • Moves the five mapping config YAMLs from the separate isp_trace_name_mapping_configs top-level package into src/isp_trace_parser/mappings/, so package data lives inside the main package rather than a sibling one.
  • Replaces the Path(__file__).parent.parent / "isp_trace_name_mapping_configs/..." functions with a simple mappings.load() helper function (that uses importlib.resources) - which I think it more standard way to access bundled package data (and behaves consistently across install layouts editable, wheel, zipped, etc).
  • Trace modules (solar_traces.py, wind_traces.py, demand_traces.py) load yamls via a single mappings.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)

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
Copy link
Copy Markdown

codecov Bot commented Apr 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/isp_trace_parser/demand_traces.py 94.11% <100.00%> (-0.23%) ⬇️
src/isp_trace_parser/mappings/__init__.py 100.00% <100.00%> (ø)
src/isp_trace_parser/solar_traces.py 100.00% <100.00%> (ø)
src/isp_trace_parser/wind_traces.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@nick-gorman nick-gorman left a comment

Choose a reason for hiding this comment

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

Looks good Dylan, definitely how we should have done it to begin with!

@dylanjmcconnell dylanjmcconnell merged commit 0140a20 into main Apr 22, 2026
18 checks passed
@dylanjmcconnell dylanjmcconnell deleted the package-data-update branch April 22, 2026 04:01
@nick-gorman nick-gorman restored the package-data-update branch May 28, 2026 02:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants