Closed singhd789 closed 1 month ago
A lot of the changes are format fixes (pylint errors)
@singhd789, here are the draft AM5 pp.yamls I've been working with:
main yaml: https://gitlab.gfdl.noaa.gov/Chris.Blanton/am5xml/-/blob/pp-yamls2/xml_include/am5.yaml
and one of the pp yamls: https://gitlab.gfdl.noaa.gov/Chris.Blanton/am5xml/-/blob/pp-yamls2/xml_include/yaml_include/pp.c96_amip.yaml
There are a couple needed "tricks" to make this work the way I have them there.
One is that in order to have the child yaml see the user variables defined in the main yaml, the yaml must be parsed together in python, not separately.
Second is that the loader needs a custom "join" constructor. To use it,
def join(loader, node):
seq = loader.construct_sequence(node)
return ''.join([str(i) for i in seq])
yaml.add_constructor('!join', join)
combined = open('combined.yaml')
data = yaml.load(combined, yaml.Loader)
I stole this from: https://stackoverflow.com/questions/5484016/how-can-i-do-string-concatenation-or-string-replacement-in-yaml/56658597#56658597
Third, the 3 special build-in FRE properties-- name, platform, and target-- must be custom added to the yaml before parsing. e.g. prepend this to the combined.yaml
:
define: &name "myname"
define: &platform "myplatform"
define: &target "mytarget"
@ceblanton oh yep! I think it can be merged in. I forgot it was still in draft mode