Skip to content

Bespoke approach to package data [Use importlib.resources instead] #35

@dylanjmcconnell

Description

@dylanjmcconnell

Issue

We currently have a fairly unusual / non-standard approach to managing and accessing package data / resources (e.g. like yaml files containing mapping config files - solar_project_mapping.yaml etc).

These are are currently essentially in separate top level package (isp_trace_name_mapping_configs) and accessed using Path(__file__).parent.parent. This which but isn't the canonical approach for package data (and is a little fragile, might break / not work in certain install environments).

Possible solutions

I would suggest moving the mappings into the main package - something like:

src/isp_trace_parser/
└── mappings/
   ├── init.py
   └── *.yaml

Then use importlib.resources for loading:

from importlib.resources import files
trace_name_mappings = files("isp_trace_parser.mappings")

(or something similar / more explicit as necessary)

Which I think follows standard conventions better (and will work better across different install environments / types).

Semi relates to #33 (with respect to how/where the scenario name mappings are).

Metadata

Metadata

Assignees

No one assigned

    Labels

    category: tech-debtRefactorings / improving code and internal structure for maintainability etc

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions