dvc: ignore Stage.meta in md5 calculations

Meta change surely should not trigger a repro run. Closes #2209.
This commit is contained in:
Alexander Schepanovski
2019-07-23 16:00:22 +03:00
parent f00a325114
commit 35a8d69c4f
2 changed files with 35 additions and 43 deletions
+3 -3
View File
@@ -657,9 +657,9 @@ class Stage(object):
d = self.dumpd()
# NOTE: removing md5 manually in order to not affect md5s in deps/outs
if self.PARAM_MD5 in d.keys():
del d[self.PARAM_MD5]
# Remove md5 and meta, these should not affect stage md5
d.pop(self.PARAM_MD5, None)
d.pop(self.PARAM_META, None)
# Ignore the wdir default value. In this case DVC-file w/o
# wdir has the same md5 as a file with the default value specified.
+32 -40
View File
@@ -7,51 +7,43 @@ import pytest
from unittest import TestCase
class TestStageChecksum(TestCase):
def test(self):
stage = Stage(None, "path")
outs = [{"path": "a", "md5": "123456789"}]
deps = [{"path": "b", "md5": "987654321"}]
d = {"md5": "123456", "cmd": "mycmd", "outs": outs, "deps": deps}
TEST_STAGE_DICT = {
"md5": "123456",
"cmd": "mycmd",
"outs": [{"path": "a", "md5": "123456789"}],
"deps": [{"path": "b", "md5": "987654321"}],
}
with mock.patch.object(stage, "dumpd", return_value=d):
self.assertEqual(
stage._compute_md5(), "e9521a22111493406ea64a88cda63e0b"
)
def test_wdir_default_ignored(self):
stage = Stage(None, "path")
outs = [{"path": "a", "md5": "123456789"}]
deps = [{"path": "b", "md5": "987654321"}]
d = {
"md5": "123456",
"cmd": "mycmd",
"outs": outs,
"deps": deps,
"wdir": ".",
}
def test_stage_checksum():
stage = Stage(None, "path")
with mock.patch.object(stage, "dumpd", return_value=d):
self.assertEqual(
stage._compute_md5(), "e9521a22111493406ea64a88cda63e0b"
)
with mock.patch.object(stage, "dumpd", return_value=TEST_STAGE_DICT):
assert stage._compute_md5() == "e9521a22111493406ea64a88cda63e0b"
def test_wdir_non_default_is_not_ignored(self):
stage = Stage(None, "path")
outs = [{"path": "a", "md5": "123456789"}]
deps = [{"path": "b", "md5": "987654321"}]
d = {
"md5": "123456",
"cmd": "mycmd",
"outs": outs,
"deps": deps,
"wdir": "..",
}
with mock.patch.object(stage, "dumpd", return_value=d):
self.assertEqual(
stage._compute_md5(), "2ceba15e87f6848aa756502c1e6d24e9"
)
def test_wdir_default_ignored():
stage = Stage(None, "path")
d = dict(TEST_STAGE_DICT, wdir=".")
with mock.patch.object(stage, "dumpd", return_value=d):
assert stage._compute_md5() == "e9521a22111493406ea64a88cda63e0b"
def test_wdir_non_default_is_not_ignored():
stage = Stage(None, "path")
d = dict(TEST_STAGE_DICT, wdir="..")
with mock.patch.object(stage, "dumpd", return_value=d):
assert stage._compute_md5() == "2ceba15e87f6848aa756502c1e6d24e9"
def test_meta_ignored():
stage = Stage(None, "path")
d = dict(TEST_STAGE_DICT, meta={"author": "Suor"})
with mock.patch.object(stage, "dumpd", return_value=d):
assert stage._compute_md5() == "e9521a22111493406ea64a88cda63e0b"
class TestPathConversion(TestCase):