impactlab / eemeter

‼️ MOVED TO https://github.com/openeemeter/eemeter - Core computation engine for the Open Energy Efficiency Meter
https://eemeter.readthedocs.io/
MIT License
25 stars 13 forks source link

Yaml -> meter is possible; make meter-> yaml possible #73

Closed philngo closed 8 years ago

philngo commented 9 years ago

This would make it a bit easier to construct modular components for subbing into other meters.

hunterowens commented 8 years ago

Taking a stab at this. Any thoughts?

philngo commented 8 years ago

pyyaml which we're using for parsing may have some helpful yaml writing tools, but I haven't looked closely. This may be a bit of a hairy issue for meters like the DefaultResidentialMeter (previously PRISMMeter), which use meter yaml internally, but aren't directly instantiated from YAML, but should be much more straightforward for other meters.

The meters to pay particularly close attention to are those defined in eemeter.meter.control, which provide control flow by calling other sub meters. For example, the Sequential Meter has a special attribute sequence, which contains a list of meters which should also be serialized to YAML.

hunterowens commented 8 years ago

Ok. thanks

hunterowens commented 8 years ago

So one think to think about is that JSON and therefore __dict__ is valid yaml?

philngo commented 8 years ago

Here's a first pass at this - it doesn't take advantage of the similarity to json, but it does fit in nicely with the existing framework for loading yaml.

https://github.com/impactlab/eemeter/compare/3c2313af108490a9645178f946f0dd4a74abca03...29a6153eabd8e5c0be57c58fbbd8a9cb38a69dda

Haven't yet tried reading the dumped yaml back in, but that's probably the best way to test it.

We might also consider adding in a comment somewhere in the output for eemeter version compatibility.

hunterowens commented 8 years ago

Pretty impressive work, I wouldn't have come up with this in ages. :+1: :fireworks:

hunterowens commented 8 years ago

I can take a look tomorrow at the latter two issues.