mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-11 23:10:10 +01:00
Merge pull request #1877 from mroutis/fix-1852
repro: persisting outputs invalidates build cache
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user