mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
parsing: Add key to matrix stages
This commit adds the `key` property to the templaing context of `matrix`
stages. Similarly to `foreach` stages, the `key` is available using
`${key}` substitution.
Fixes #10043
This commit is contained in:
committed by
Dave Berenbaum
parent
d60557dd08
commit
fcc69ab6eb
@@ -50,3 +50,47 @@ def test_matrix_interpolated(tmp_dir, dvc, matrix):
|
||||
"[email protected]": {"cmd": "echo linux 3.8 --arg2 2 -- out1 out11"},
|
||||
"[email protected]": {"cmd": "echo linux 3.8 --arg2 2 -- out2 out22"},
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"matrix",
|
||||
[
|
||||
MATRIX_DATA,
|
||||
{
|
||||
"os": "${os}",
|
||||
"pyv": "${pyv}",
|
||||
"dict": "${dict}",
|
||||
"list": "${list}",
|
||||
},
|
||||
],
|
||||
)
|
||||
def test_matrix_key_present(tmp_dir, dvc, matrix):
|
||||
(tmp_dir / "params.yaml").dump(MATRIX_DATA)
|
||||
resolver = DataResolver(dvc, tmp_dir.fs_path, {})
|
||||
data = {
|
||||
"matrix": matrix,
|
||||
"cmd": "echo ${key}",
|
||||
}
|
||||
definition = MatrixDefinition(resolver, resolver.context, "build", data)
|
||||
|
||||
assert definition.resolve_all() == {
|
||||
f"build@{key}": {"cmd": f"echo {key}"}
|
||||
for key in (
|
||||
"win-3.7-dict0-list0",
|
||||
"win-3.7-dict0-list1",
|
||||
"win-3.7-dict1-list0",
|
||||
"win-3.7-dict1-list1",
|
||||
"win-3.8-dict0-list0",
|
||||
"win-3.8-dict0-list1",
|
||||
"win-3.8-dict1-list0",
|
||||
"win-3.8-dict1-list1",
|
||||
"linux-3.7-dict0-list0",
|
||||
"linux-3.7-dict0-list1",
|
||||
"linux-3.7-dict1-list0",
|
||||
"linux-3.7-dict1-list1",
|
||||
"linux-3.8-dict0-list0",
|
||||
"linux-3.8-dict0-list1",
|
||||
"linux-3.8-dict1-list0",
|
||||
"linux-3.8-dict1-list1",
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user