dvc: introduce local build cache (#3603)

This patch introduces `.dvc/cache/stages` that is used to store previous
runs and their results, which could then be reused later when we stumble
upon the same command with the same deps and outs.

Format of build cache entries is single-line json, which is readable by
humans and might also be used for lock files discussed in #1871.

Related to #1871
Local part of #1234
This commit is contained in:
Ruslan Kuprieiev
2020-04-30 00:22:32 +03:00
committed by GitHub
parent 8aefbac223
commit 18e8f07572
10 changed files with 223 additions and 17 deletions
+2
View File
@@ -1,4 +1,5 @@
import logging
import shutil
import os
import configobj
@@ -341,6 +342,7 @@ def test_gc_not_collect_pipeline_tracked_files(tmp_dir, dvc, run_copy):
tmp_dir.gen("bar", "bar")
run_copy("foo", "foo2", name="copy")
shutil.rmtree(dvc.stage_cache.cache_dir)
assert _count_files(dvc.cache.local.cache_dir) == 1
dvc.gc(workspace=True, force=True)
assert _count_files(dvc.cache.local.cache_dir) == 1
+3 -1
View File
@@ -1295,7 +1295,9 @@ class TestReproNoCommit(TestRepro):
["repro", self._get_stage_target(self.stage), "--no-commit"]
)
self.assertEqual(ret, 0)
self.assertFalse(os.path.exists(self.dvc.cache.local.cache_dir))
self.assertEqual(
os.listdir(self.dvc.cache.local.cache_dir), ["stages"]
)
class TestReproAlreadyCached(TestRepro):