mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-24 15:28:28 +01:00
parametrization: Support keys of the dictionary to be interpolated (#4869)
This commit is contained in:
@@ -297,7 +297,7 @@ class Context(CtxDict):
|
||||
|
||||
resolve = rpartial(self.resolve, unwrap)
|
||||
if isinstance(src, Mapping):
|
||||
return {key: resolve(value) for key, value in src.items()}
|
||||
return dict(map(resolve, kv) for kv in src.items())
|
||||
elif isinstance(src, Seq):
|
||||
return type(src)(map(resolve, src))
|
||||
elif isinstance(src, str):
|
||||
|
||||
@@ -370,3 +370,12 @@ def test_node_value():
|
||||
assert context["lst"][1].value == 2
|
||||
|
||||
assert context["foo"].value == "foo"
|
||||
|
||||
|
||||
def test_resolve_resolves_dict_keys():
|
||||
d = {"dct": {"foo": "foobar", "persist": True}}
|
||||
|
||||
context = Context(d)
|
||||
assert context.resolve({"${dct.foo}": {"persist": "${dct.persist}"}}) == {
|
||||
"foobar": {"persist": True}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user