repro: persisting outputs invalidates build cache

Fix #1852
This commit is contained in:
Mr. Outis
2019-04-24 16:45:03 -07:00
parent 165f6472ca
commit d42c8fbd14
2 changed files with 35 additions and 0 deletions
+4
View File
@@ -502,6 +502,10 @@ class Stage(object):
else:
stage.unprotect_outs()
if os.path.exists(path) and any(out.persist for out in stage.outs):
logger.warning("Build cache is ignored when persisting outputs.")
ignore_build_cache = True
if validate_state:
if os.path.exists(path):
if not ignore_build_cache and stage.is_cached:
+31
View File
@@ -1,6 +1,7 @@
import os
import uuid
import logging
import mock
import shutil
import filecmp
@@ -948,3 +949,33 @@ class TestShouldNotCheckoutUponCorruptedLocalHardlinkCache(TestDvc):
mock_run.assert_called_once()
mock_checkout.assert_not_called()
class TestPersistentOutput(TestDvc):
def test_ignore_build_cache(self):
warning = "Build cache is ignored when persisting outputs."
with open("immutable", "w") as fobj:
fobj.write("1")
cmd = [
"run",
"--overwrite-dvcfile",
"--deps",
"immutable",
"--outs-persist",
"greetings",
"echo hello>>greetings",
]
with self._caplog.at_level(logging.WARNING, logger="dvc"):
assert main(cmd) == 0
assert warning not in self._caplog.text
assert main(cmd) == 0
assert warning in self._caplog.text
# Even if the "immutable" dependency didn't change
# it should run the command again, as it is "ignoring build cache"
with open("greetings", "r") as fobj:
assert "hello\nhello\n" == fobj.read()