Improve YAML serialization.
For #150.
Creates a custom_yaml object that has alternative "representers" registered to it to modify the default output structures.
Summary:
tupleis treated as a listsetis treated as a list, but is sorted to ensure that they're serialized in a deterministic way.PurePathand subclasses are stringifiedReportType,ScheduleType, andSimTimehaveyaml_representerstatic methods and are registered to thecustom_yamlobject in thecustom_yaml.pyfile.- A generic representer is registered on
objectand its subclasses to catch anything else that is passed in. It creates aWARNING-level log entry to prompt the user that an "implicit" serialization was performed. ReportTypehad__lt__defined so that aset[ReportType]could be deterministically serialized, as mentioned above.
Some mediocre testing was included.
NOTE: I believe that import yaml and from nrel...custom_yaml import custom_yaml as yaml both import the same object, so it's not clear to me if the unmodified yaml package would be available. The "package-local" import was still used to make it clear that it is modified.
The output .yml can not be directly imported because the code currently expects an input key, but the output includes an input_config key.
@nreinicke advised that outputing an input key rather than input_config was acceptable. I can try to investigate this change and include it in this PR.