mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-10 07:18:27 +01:00
parametrization: change foreach stage name joiner from "-" to "@" (#4929)
This commit is contained in:
@@ -41,7 +41,7 @@ SET_KWD = "set"
|
||||
|
||||
DEFAULT_SENTINEL = object()
|
||||
|
||||
JOIN = "-"
|
||||
JOIN = "@"
|
||||
|
||||
|
||||
class ResolveError(DvcException):
|
||||
|
||||
@@ -264,7 +264,7 @@ def test_simple_foreach_loop(tmp_dir, dvc):
|
||||
resolver.resolve(),
|
||||
{
|
||||
"stages": {
|
||||
f"build-{item}": {"cmd": f"python script.py {item}"}
|
||||
f"build@{item}": {"cmd": f"python script.py {item}"}
|
||||
for item in iterable
|
||||
}
|
||||
},
|
||||
@@ -287,7 +287,7 @@ def test_foreach_loop_dict(tmp_dir, dvc):
|
||||
resolver.resolve(),
|
||||
{
|
||||
"stages": {
|
||||
f"build-{key}": {"cmd": f"python script.py {item['thresh']}"}
|
||||
f"build@{key}": {"cmd": f"python script.py {item['thresh']}"}
|
||||
for key, item in iterable["models"].items()
|
||||
}
|
||||
},
|
||||
@@ -313,8 +313,8 @@ def test_foreach_loop_templatized(tmp_dir, dvc):
|
||||
resolver.resolve(),
|
||||
{
|
||||
"stages": {
|
||||
"build-gb": {"cmd": "python script.py --thresh 15"},
|
||||
"build-us": {
|
||||
"build@gb": {"cmd": "python script.py --thresh 15"},
|
||||
"build@us": {
|
||||
"cmd": "python script.py --thresh 10",
|
||||
"params": ["models.us.thresh"],
|
||||
},
|
||||
@@ -390,7 +390,7 @@ def test_set_with_foreach(tmp_dir, dvc):
|
||||
resolver.resolve(),
|
||||
{
|
||||
"stages": {
|
||||
f"build-{item}": {"cmd": f"command --value {item}"}
|
||||
f"build@{item}": {"cmd": f"command --value {item}"}
|
||||
for item in items
|
||||
}
|
||||
},
|
||||
@@ -419,11 +419,11 @@ def test_set_with_foreach_and_on_stage_definition(tmp_dir, dvc):
|
||||
resolver.resolve(),
|
||||
{
|
||||
"stages": {
|
||||
"build-us": {
|
||||
"build@us": {
|
||||
"cmd": "command --value 10",
|
||||
"params": [{"params.json": ["models.us.thresh"]}],
|
||||
},
|
||||
"build-gb": {
|
||||
"build@gb": {
|
||||
"cmd": "command --value 15",
|
||||
"params": [{"params.json": ["models.gb.thresh"]}],
|
||||
},
|
||||
|
||||
@@ -202,7 +202,7 @@ def test_foreach_generated_errors(tmp_dir, repo, syn, msg):
|
||||
with pytest.raises(ResolveError) as exc_info:
|
||||
resolver.resolve()
|
||||
assert str(exc_info.value) == (
|
||||
"failed to parse 'stages.build-bar.cmd' in 'dvc.yaml':" + msg
|
||||
"failed to parse '[email protected]' in 'dvc.yaml':" + msg
|
||||
)
|
||||
|
||||
|
||||
@@ -212,7 +212,7 @@ def test_foreach_generated_errors(tmp_dir, repo, syn, msg):
|
||||
(["params-does-not-exist"], " 'params-does-not-exist' does not exist"),
|
||||
(
|
||||
[DATA],
|
||||
"\ncannot redefine 'models.bar' from 'build-bar.vars[0]' "
|
||||
"\ncannot redefine 'models.bar' from 'build@bar.vars[0]' "
|
||||
f"as it already exists in '{DEFAULT_PARAMS_FILE}'",
|
||||
),
|
||||
],
|
||||
@@ -230,7 +230,7 @@ def test_foreach_generated_local_vars_error(tmp_dir, repo, vars_, msg):
|
||||
with pytest.raises(ResolveError) as exc_info:
|
||||
resolver.resolve()
|
||||
assert str(exc_info.value) == (
|
||||
"failed to parse stage 'build-bar' (gen. from 'build') in 'dvc.yaml':"
|
||||
"failed to parse stage 'build@bar' (gen. from 'build') in 'dvc.yaml':"
|
||||
+ msg
|
||||
)
|
||||
|
||||
@@ -261,7 +261,7 @@ def test_foreach_wdir_interpolation_issues(tmp_dir, repo, wdir, msg):
|
||||
with pytest.raises(ResolveError) as exc_info:
|
||||
resolver.resolve()
|
||||
assert str(exc_info.value) == (
|
||||
"failed to parse 'stages.build-bar.wdir' in 'dvc.yaml':" + msg
|
||||
"failed to parse '[email protected]' in 'dvc.yaml':" + msg
|
||||
)
|
||||
|
||||
|
||||
@@ -323,7 +323,7 @@ def test_item_key_in_generated_stage_vars(tmp_dir, repo, foreach, redefine):
|
||||
with pytest.raises(ResolveError) as exc_info:
|
||||
resolver.resolve()
|
||||
assert str(exc_info.value) == (
|
||||
f"attempted to redefine '{redefine}' in stage 'build-bar'"
|
||||
f"attempted to redefine '{redefine}' in stage 'build@bar'"
|
||||
" generated through 'foreach'"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user