Conversation
mranst
left a comment
There was a problem hiding this comment.
Nice, thanks for working on this. Did you find dumping in safe mode vs round-trip has an effect on key order? My impression was that it shouldn't make a difference, but it shouldn't hurt anything either
Yeah, safe mode operates more like PyYAML and reorders keys alphabetically. This PR way |
|
This is ready for a review. Some notes:
|
mranst
left a comment
There was a problem hiding this comment.
Looks good, and I see tier tests pass
Thanks, I will give it a few more days to see if there are any more reviews then we can merge. |
This switches SWELL handling of YAMLs fully with
ruamel. To accommodate JEDI executables and EVA and R2D2, I had to usesafemode for loading andrtmode for dumping.ConstructorErrorwhen passing data to EVA, which still uses PyYAML.rtmode preserves the key ordercreate_experiment.pyanddictionary.py), I have implemented io.StringIO to capture the YAML output correctly before further processing.Checks most of the boxes:
Does not resolve the anchor request: #558
Helpful tip: In
experiment.yaml, usinggenerate_yaml_and_exitkey helps testing different ruamel modesSome notes for any future user stumbled upon this PR:
observing_system_records.pyfor using "Flow Style" output. It improves readability and doesn't break the code.rtmodeyaml.representer.ignore_aliases = lambda *data: True, which explicitly writes the hook/anchor aliases, rather than assigningid***. Might be an answer for Alternative handling of anchor variables #558yaml.sort_base_mapping_type_on_output = False. This preserves key order but only works for JSON-like outputs. I personally prefer preserving key orders but don't mind about JSON-like outputs as long as EVA doesn't complain. Update: it doesn't work for eva_observations for some reason..