add base.context.dump to save experiment config as metadata - #131
Conversation
e4ae491 to
0b4186f
Compare
|
hi @uwefladrich . I am implementing "saveic" in ECE4. To make saved initial conditions fully self-documenting and traceable, I'd like saveic to also save a snapshot of the experiment config that defines the model setup (component list, resolutions/grids, forcing settings, and dates) that generated those initial conditions. I did not find an easy way to dump from ScriptEngine in-memory context. With the new and render it I hope this PR makes sense to you. Let me know if there is a better way to achieve the same. |
b41fb84 to
6c097db
Compare
|
when testing, I realized implementing a So, I decided to add |
feaecca to
ec59b4d
Compare
164c46f to
b0499c9
Compare
|
I thought about copying the input file but it's fragile (cli args position uncertain, can be more than 1). So, Also, some meaningful context, added via base.include can be missed (such as model tuning presets). It can also filter out platform and job context to the model physics and experiment parameters.
|
b0499c9 to
da33f7a
Compare
|
Hi @vlap, thanks for the PR! Reasonable to have a The main point is that
This is not a show stopper, rather the nature of So I am fine to go ahead with this new feature! 😃 One more technical question: You added duplicated constructors like what's the reason for that? I don't doubt it, I am just not familiar with this procedure. |
|
Hi Uwe, Thank you for the review. Agreed, it's not a true counter part to base.context.load. It is supposed to be a snapshot of the model runtime dictionary. Plus representers to handle tags. Clarifying this distinction in the documentation (that base.context.dump dumps model state context rather than re-creating SE scripts) is the right call. Regarding the duplicated constructor (SafeLoader), it was added to allow calling base.context.load on the output of base.context.dump. (base.context.load (and SEContext.load_from_yaml) uses Loader=yaml.SafeLoader) But there is no real use-case for it that I can think of. There is already Happy to have assign |
|
I simplified this PR a bit. Hope it is more transparent now. Tested to work. Let me know if there are other doubts. |
|
Great, I like it 👍 Also, nice to have the option to give a list of keys! I would keep the name Will merge later today! |
Adds
toyaml(andto_yamlalias) Jinja filter to dump SE context as a yaml file (via yaml.dump).