hydra: resolve OmegaConf interpolations. (#9212)

Closes #9196
This commit is contained in:
David de la Iglesia Castro
2023-03-20 21:38:22 +05:45
committed by GitHub
parent 66406e6c99
commit 121d56b739
2 changed files with 17 additions and 1 deletions
+15 -1
View File
@@ -178,7 +178,7 @@ def test_compose_and_dump(tmp_dir, suffix, overrides, expected):
def test_compose_and_dump_yaml_handles_string(tmp_dir):
"""Regression test for 8583"""
"""Regression test for https://github.com/iterative/dvc/issues/8583"""
from dvc.utils.hydra import compose_and_dump
config = tmp_dir / "conf" / "config.yaml"
@@ -189,6 +189,20 @@ def test_compose_and_dump_yaml_handles_string(tmp_dir):
assert output_file.read_text() == "foo: 'no'\n"
def test_compose_and_dump_resolves_interpolation(tmp_dir):
"""Regression test for https://github.com/iterative/dvc/issues/9196"""
from dvc.utils.hydra import compose_and_dump
config = tmp_dir / "conf" / "config.yaml"
config.parent.mkdir()
config.dump({"data": {"root": "path/to/root", "raw": "${.root}/raw"}})
output_file = tmp_dir / "params.yaml"
compose_and_dump(output_file, str(config.parent), "config", [])
assert output_file.parse() == {
"data": {"root": "path/to/root", "raw": "path/to/root/raw"}
}
@pytest.mark.parametrize(
"overrides, expected",
[