pavilion2
pavilion2 copied to clipboard
Merge variable sub-var-dicts by default.
After talking to Francine, I'm changing the behavior of how sub-variables merge via inheritance.
Given the following configuration:
lvl1:
variables:
var:
a: A1
lvl2:
inherits_from: lvl1
variables:
var?:
a: A2
b: B2
c: C2
lvl3:
inherits_from: lvl2
variables:
var:
c: C3
lvl4:
inherits_from: lvl3
variables:
var:
- b: B4_1
- b: B4_2
lvl5:
inherits_from: lvl4
variables:
var:
c: C5
We would currently get a single var
item with the values {a: A2, b: B2, c: C5}
in the test lvl5
.
This is because setting var
in lvl5
would completely replace var
from lvl4.
For the lvl4
test, we would get two items with b
set correctly, but we would lose the host settings for a
and the lvl3
settings for c
.
What we decided should be the expected behavior is the following:
lvl1 var - {a: A1}
# Same as current behavior
lvl2 var - {a: A1, b: B2, c: C2}
# Same as current.
lvl3 var - {a: A1, b: B2, c: C3}
# The new setting is overlaid on the old by default.
lvl4 var - [{a: A1, b: B4_1, c: C3}, ...]
# Each new item is overlaid on the prior item.
lvl5 var - [{a: A1, b: B4_1, c: C5}, ...]
# The new setting is overlaid on each old item.
If lvl5 had multiple items for var, that would be an error. However, if it used the plus operator var+
, that would extend the list, with the new values being overlayed on copies of last item in the old list.
This will also add a new operator: var!
. Using this will force the old behavior.