mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
hydra: Use OmegaConf.to_yaml for dumping .yaml output. (#8587)
* hydra: Use `OmegaConf.to_yaml` for dumping `.yaml` output. Combining `OmegaConf.to_object` with our yaml DUMPER (ruaml.yaml) was not correctly handling strings like 'no'. `OmegaConf.to_yaml` uses a custom string representer that correctly handles those cases. Fixes #8583 * Update dvc/utils/hydra.py Co-authored-by: Dave Berenbaum <[email protected]> Co-authored-by: Dave Berenbaum <[email protected]>
This commit is contained in:
co-authored by
Dave Berenbaum
parent
dae500d7c7
commit
b0a92414fa
@@ -174,12 +174,25 @@ def test_compose_and_dump(tmp_dir, suffix, overrides, expected):
|
||||
from dvc.utils.hydra import compose_and_dump
|
||||
|
||||
config_name = "config"
|
||||
config_dir = hydra_setup(tmp_dir, "conf", "config")
|
||||
output_file = tmp_dir / f"params.{suffix}"
|
||||
config_dir = hydra_setup(tmp_dir, "conf", "config")
|
||||
compose_and_dump(output_file, config_dir, config_name, overrides)
|
||||
assert output_file.parse() == expected
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.version_info >= (3, 11), reason="unsupported on 3.11")
|
||||
def test_compose_and_dump_yaml_handles_string(tmp_dir):
|
||||
"""Regression test for 8583"""
|
||||
from dvc.utils.hydra import compose_and_dump
|
||||
|
||||
config = tmp_dir / "conf" / "config.yaml"
|
||||
config.parent.mkdir()
|
||||
config.write_text("foo: 'no'\n")
|
||||
output_file = tmp_dir / "params.yaml"
|
||||
compose_and_dump(output_file, str(config.parent), "config", [])
|
||||
assert output_file.read_text() == "foo: 'no'\n"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"overrides, expected",
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user