energyPATHWAYS / EnergyPATHWAYS

EnergyPATHWAYS model is a professional, open-source energy and carbon planning tool for use in evaluating long-term, economy-wide greenhouse gas mitigation scenarios.
MIT License
45 stars 15 forks source link

Move unit definitions to database #64

Open mactyr opened 8 years ago

mactyr commented 8 years ago

As a pathways developer-user I want my custom unit definitions to be part of my database so that when I want to share my model, I just need to move one database dump around, rather than having to remember to send my custom unit definition file separately.

AC

  1. Move unit definitions into a new table / SQLAlchemy model (probably just a two-column table with unit name and definition, though it looks like pint also allows for unit aliases so we may want a third column for that). Enforce uniqueness and not-null constraints where possible.
  2. Remove unit_defs.txt
  3. Update readme.md as necessary to remove references to unit_defs.txt

Notes

This work should be done on the data_access branch so the SQLAlchemy infrastructure is available.

We are currently loading unit definitions using pint's UnitRegistry.load_definitions(), which expects a text file. However, it looks like we could easily loop through a database table and create the units one at a time instead.