Skip to content

Commit dd2d2dc

Browse files
daavoopmrowla
andcommitted
param: Fix status check for Tuples.
Closes #8803 Update dvc/dependency/param.py Co-authored-by: Peter Rowlands (변기호) <peter@pmrowla.com>
1 parent 5f558d0 commit dd2d2dc

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

dvc/dependency/param.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,14 @@ def workspace_status(self):
125125
elif param not in info:
126126
st = "new"
127127
elif actual[param] != info[param]:
128-
st = "modified"
128+
if (
129+
isinstance(actual[param], tuple)
130+
and list(actual[param]) == info[param]
131+
):
132+
continue
133+
else:
134+
st = "modified"
129135
else:
130-
assert actual[param] == info[param]
131136
continue
132137

133138
status[str(self)][param] = st

tests/unit/dependency/test_params.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,22 @@ def test_read_params_py(tmp_dir, dvc):
207207
assert dep.read_params() == {"x": 4, "Klass.a": "val1"}
208208

209209

210+
def test_params_py_tuple_status(tmp_dir, dvc):
211+
"""https://github.com/iterative/dvc/issues/8803"""
212+
parameters_file = "parameters.py"
213+
tmp_dir.gen(parameters_file, "TUPLE = (10, 100)\n")
214+
dep = ParamsDependency(Stage(dvc), parameters_file, ["TUPLE"])
215+
# lock file uses YAML so the tuple will be loaded as a list
216+
dep.fill_values({"TUPLE": [10, 100]})
217+
assert dep.status() == {}
218+
dep.fill_values({"TUPLE": [11, 100]})
219+
assert dep.status() == {"parameters.py": {"TUPLE": "modified"}}
220+
dep.fill_values({"TUPLE": [10]})
221+
assert dep.status() == {"parameters.py": {"TUPLE": "modified"}}
222+
dep.fill_values({"TUPLE": {10: "foo", 100: "bar"}})
223+
assert dep.status() == {"parameters.py": {"TUPLE": "modified"}}
224+
225+
210226
def test_get_hash_missing_config(dvc):
211227
dep = ParamsDependency(Stage(dvc), None, ["foo"])
212228
with pytest.raises(MissingParamsError):

0 commit comments

Comments
 (0)