Skip to content

Commit

Permalink
parametrization: Support keys of the dictionary to be interpolated (i…
Browse files Browse the repository at this point in the history
  • Loading branch information
skshetry authored Nov 10, 2020
1 parent 2e9fa06 commit 4220baa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dvc/parsing/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def resolve(self, src, unwrap=True):

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):
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}

0 comments on commit 4220baa

Please sign in to comment.