-
Notifications
You must be signed in to change notification settings - Fork 88
Description
EDIT: I think I've narrowed down the problem more, so I would skip to the 3rd and 4th comment in this issue to start
This issue is meant to accompany the corresponding reproducer I will send to @oehmke
You have two hconfigs from 2 yaml files that define that same key:
In the subsequent examples I will refer to the following 2 yaml files as c1 and c2 respectively
Collections:
c1: {template: foo1}
Exports:
e1: {collection: c1}
and
Collections:
c2: {template: foo2}
Exports:
e2: {collection: c2}
you want to merge them into a single, new hconfig (I will refer to this as merged_config) that will look like this.
Collections:
c1: {template: foo1}
c2: {template: foo2}
Exports:
e1: {collection: c1}
e2: {collection: c2}
I will separately send the code used to merge these two. The code basically has a procedure that has the "from" hconfig and "to" hconfig. Lets assume that the "from" has the key you want to merge.
Then it checks, is that key in the "to" hconfig.
If not it just add the value of the key in the "from" to the "to" using ESMF_HConfigAdd.
If they "to" has it. Then it iterates over the key in both configs to create a new hconfig. The they key is set to this in the "to" hconfig using ESMF_HConfigSet
I am unable to merge these two hconfigs together. At the end of the day the culprit seems to be that after adding the key, even to an empty HConfig use ESMF_HConfigAdd; ESMF_HconfigIsDefined says the key does not exist.
There are two cases I've tried.
Case 1
hconfigs for c1 and c2 hard coded in source using ESMF_HConfigCreate(content=...
merged_config created as an empty map using ESMF_HConfigCreate(content='{}')
This produces a file with duplicate keys because after adding a key using EMSF_HConfigAdd, IsDefined says there is not key with that name!
Collections:
c1: {template: foo1}
Exports:
e1: {coll: c1}
Collections:
c2: {template: foo2}
Exports:
e2: {coll: c2}
Case2
hconfigs for c1 and c2 hard coded in source using ESMF_HConfigCreate(content=...
merged_config with no arguments using ESMF_HConfigCreate()
However, to use this, you must not check the return code of ESMF_HConfigIsDefined which is an issue as well
That manages to merge one key
Collections:
c2: {template: foo2}
c1: {template: foo1}
Exports: {e1: {coll: c1}}
Exports: {e2: {coll: c2}}