mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
- Overriding a config value : foo.bar=value - Appending a config value : +foo.bar=value - Appending or overriding a config value : ++foo.bar=value - Removing a config value : ~foo.bar, ~foo.bar=value See https://hydra.cc/docs/advanced/override_grammar/basic/#modifying-the-config-object --- Breaking changes: To modify a list, `foo[0]=bar` must now be passed as `foo.0=bar`. Modifying a nested list inside a dictionary is not supported by omegaconf. --- Closes #4883 Closes #5868 Closes #6129
43 lines
1.1 KiB
Python
43 lines
1.1 KiB
Python
import pytest
|
|
|
|
from dvc.utils.cli_parse import parse_params, to_path_overrides
|
|
|
|
|
|
def test_parse_params():
|
|
assert parse_params(
|
|
[
|
|
"param1",
|
|
"file1:param1,param2",
|
|
"file2:param2",
|
|
"file1:param3,param4,",
|
|
"param2,param10",
|
|
"param3,",
|
|
"file3:",
|
|
]
|
|
) == [
|
|
{"params.yaml": ["param1", "param2", "param10", "param3"]},
|
|
{"file1": ["param1", "param2", "param3", "param4"]},
|
|
{"file2": ["param2"]},
|
|
{"file3": []},
|
|
]
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"params,expected",
|
|
[
|
|
(["foo=1"], {"params.yaml": ["foo=1"]}),
|
|
(["foo={bar: 1}"], {"params.yaml": ["foo={bar: 1}"]}),
|
|
(["foo.0=bar"], {"params.yaml": ["foo.0=bar"]}),
|
|
(["params.json:foo={bar: 1}"], {"params.json": ["foo={bar: 1}"]}),
|
|
(
|
|
["params.json:foo={bar: 1}", "baz=2", "goo=3"],
|
|
{
|
|
"params.json": ["foo={bar: 1}"],
|
|
"params.yaml": ["baz=2", "goo=3"],
|
|
},
|
|
),
|
|
],
|
|
)
|
|
def test_to_path_overrides(params, expected):
|
|
assert to_path_overrides(params) == expected
|