mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-26 07:18:31 +01:00
repo: rename odb -> cache
We used to have it named `cache` before, but these days it is clear that you can have three odbs: just odb (e.g. in-memory), cache (typically local) or remote (typically cloud). Fixing naming here before proceeding with introducing `out.odb` and `out.cache`. In preparation for migration to https://github.com/iterative/dvc-data/pull/304
This commit is contained in:
@@ -44,7 +44,7 @@ def test_open_external(tmp_dir, erepo_dir, cloud):
|
||||
erepo_dir.dvc.push(all_branches=True)
|
||||
|
||||
# Remove cache to force download
|
||||
remove(erepo_dir.dvc.odb.local.path)
|
||||
remove(erepo_dir.dvc.cache.local.path)
|
||||
|
||||
# Using file url to force clone to tmp repo
|
||||
repo_url = f"file://{erepo_dir.as_posix()}"
|
||||
@@ -59,7 +59,7 @@ def test_open_granular(tmp_dir, dvc, remote):
|
||||
dvc.push()
|
||||
|
||||
# Remove cache to force download
|
||||
remove(dvc.odb.local.path)
|
||||
remove(dvc.cache.local.path)
|
||||
|
||||
with api.open("dir/foo") as fd:
|
||||
assert fd.read() == "foo-text"
|
||||
@@ -69,7 +69,7 @@ def test_missing(tmp_dir, dvc, remote):
|
||||
tmp_dir.dvc_gen("foo", "foo")
|
||||
|
||||
# Remove cache to make foo missing
|
||||
remove(dvc.odb.local.path)
|
||||
remove(dvc.cache.local.path)
|
||||
|
||||
api.read("foo")
|
||||
|
||||
@@ -129,7 +129,7 @@ def test_api_missing_local_cache_exists_on_remote(
|
||||
dvc.push()
|
||||
|
||||
# Remove cache to make foo missing
|
||||
remove(dvc.odb.local.path)
|
||||
remove(dvc.cache.local.path)
|
||||
remove(first(files))
|
||||
|
||||
repo_url = f"file://{tmp_dir.as_posix()}" if as_external else None
|
||||
@@ -202,7 +202,7 @@ def test_open_from_remote(tmp_dir, erepo_dir, cloud, local_cloud):
|
||||
erepo_dir.add_remote(config=local_cloud.config, default=True)
|
||||
erepo_dir.dvc_gen({"dir": {"foo": "foo content"}}, commit="create file")
|
||||
erepo_dir.dvc.push(remote="other")
|
||||
remove(erepo_dir.dvc.odb.local.path)
|
||||
remove(erepo_dir.dvc.cache.local.path)
|
||||
|
||||
with api.open(
|
||||
os.path.join("dir", "foo"),
|
||||
|
||||
@@ -59,7 +59,7 @@ def test_clear_on_download_err(tmp_dir, dvc, index, mocker):
|
||||
dvc.push()
|
||||
|
||||
for _, _, hi in out.obj:
|
||||
remove(dvc.odb.local.get(hi.value).path)
|
||||
remove(dvc.cache.local.get(hi.value).path)
|
||||
remove(out.fs_path)
|
||||
|
||||
assert list(index.hashes())
|
||||
|
||||
@@ -303,12 +303,12 @@ def test_push_pull_cache(
|
||||
with open(path, encoding="utf-8") as f:
|
||||
assert f.read() == str(x)
|
||||
|
||||
remove(dvc.odb.local.path)
|
||||
remove(dvc.cache.local.path)
|
||||
|
||||
dvc.experiments.pull(remote, [ref_info.name], pull_cache=True)
|
||||
for x in range(2, checkpoint_stage.iterations + 1):
|
||||
hash_ = digest(str(x))
|
||||
path = os.path.join(dvc.odb.local.path, hash_[:2], hash_[2:])
|
||||
path = os.path.join(dvc.cache.local.path, hash_[:2], hash_[2:])
|
||||
assert os.path.exists(path)
|
||||
with open(path, encoding="utf-8") as f:
|
||||
assert f.read() == str(x)
|
||||
|
||||
@@ -259,7 +259,7 @@ def test_metrics_show_overlap(tmp_dir, dvc, run_copy_metrics, clear_before_run):
|
||||
# so as it works even for optimized cases
|
||||
if clear_before_run:
|
||||
remove(data_dir)
|
||||
remove(dvc.odb.local.path)
|
||||
remove(dvc.cache.local.path)
|
||||
|
||||
dvc._reset()
|
||||
|
||||
|
||||
@@ -161,7 +161,7 @@ def test_plots_show_overlap(tmp_dir, dvc, run_copy_metrics, clear_before_run):
|
||||
# so as it works even for optimized cases
|
||||
if clear_before_run:
|
||||
remove(data_dir)
|
||||
remove(dvc.odb.local.path)
|
||||
remove(dvc.cache.local.path)
|
||||
|
||||
dvc._reset()
|
||||
|
||||
|
||||
+14
-14
@@ -12,6 +12,7 @@ import pytest
|
||||
import dvc as dvc_module
|
||||
import dvc_data
|
||||
from dvc.annotations import Annotation
|
||||
from dvc.cachemgr import CacheManager
|
||||
from dvc.cli import main
|
||||
from dvc.config import ConfigError
|
||||
from dvc.dvcfile import DVC_FILE_SUFFIX
|
||||
@@ -23,7 +24,6 @@ from dvc.exceptions import (
|
||||
RecursiveAddingWhileUsingFilename,
|
||||
)
|
||||
from dvc.fs import LocalFileSystem, system
|
||||
from dvc.odbmgr import ODBManager
|
||||
from dvc.output import (
|
||||
OutputAlreadyTrackedError,
|
||||
OutputDoesNotExistError,
|
||||
@@ -110,7 +110,7 @@ def test_add_directory(tmp_dir, dvc):
|
||||
|
||||
hash_info = stage.outs[0].hash_info
|
||||
|
||||
obj = load(dvc.odb.local, hash_info)
|
||||
obj = load(dvc.cache.local, hash_info)
|
||||
for key, _, _ in obj:
|
||||
for part in key:
|
||||
assert "\\" not in part
|
||||
@@ -407,12 +407,12 @@ def test_add_commit(tmp_dir, dvc):
|
||||
ret = main(["add", "foo", "--no-commit"])
|
||||
assert ret == 0
|
||||
assert os.path.isfile("foo")
|
||||
assert not os.path.exists(dvc.odb.local.path)
|
||||
assert not os.path.exists(dvc.cache.local.path)
|
||||
|
||||
ret = main(["commit", "foo.dvc"])
|
||||
assert ret == 0
|
||||
assert os.path.isfile("foo")
|
||||
assert dvc.odb.local.exists("acbd18db4cc2f85cedef654fccc4a4d8")
|
||||
assert dvc.cache.local.exists("acbd18db4cc2f85cedef654fccc4a4d8")
|
||||
|
||||
|
||||
def test_should_collect_dir_cache_only_once(mocker, tmp_dir, dvc):
|
||||
@@ -583,7 +583,7 @@ def test_windows_should_add_when_cache_on_different_drive(
|
||||
tmp_dir, dvc, temporary_windows_drive
|
||||
):
|
||||
dvc.config["cache"]["dir"] = temporary_windows_drive
|
||||
dvc.odb = ODBManager(dvc)
|
||||
dvc.cache = CacheManager(dvc)
|
||||
|
||||
(stage,) = tmp_dir.dvc_gen({"file": "file"})
|
||||
cache_path = stage.outs[0].cache_path
|
||||
@@ -596,12 +596,12 @@ def test_windows_should_add_when_cache_on_different_drive(
|
||||
def test_readding_dir_should_not_unprotect_all(tmp_dir, dvc, mocker):
|
||||
tmp_dir.gen("dir/data", "data")
|
||||
|
||||
dvc.odb.local.cache_types = ["symlink"]
|
||||
dvc.cache.local.cache_types = ["symlink"]
|
||||
|
||||
dvc.add("dir")
|
||||
tmp_dir.gen("dir/new_file", "new_file_content")
|
||||
|
||||
unprotect_spy = mocker.spy(dvc.odb.local, "unprotect")
|
||||
unprotect_spy = mocker.spy(dvc.cache.local, "unprotect")
|
||||
dvc.add("dir")
|
||||
|
||||
assert not unprotect_spy.mock.called
|
||||
@@ -609,13 +609,13 @@ def test_readding_dir_should_not_unprotect_all(tmp_dir, dvc, mocker):
|
||||
|
||||
|
||||
def test_should_not_checkout_when_adding_cached_copy(tmp_dir, dvc, mocker):
|
||||
dvc.odb.local.cache_types = ["copy"]
|
||||
dvc.cache.local.cache_types = ["copy"]
|
||||
|
||||
tmp_dir.dvc_gen({"foo": "foo", "bar": "bar"})
|
||||
|
||||
shutil.copy("bar", "foo")
|
||||
|
||||
copy_spy = mocker.spy(dvc.odb.local.fs, "copy")
|
||||
copy_spy = mocker.spy(dvc.cache.local.fs, "copy")
|
||||
|
||||
dvc.add("foo")
|
||||
|
||||
@@ -637,11 +637,11 @@ def test_should_relink_on_repeated_add(link, new_link, link_test_func, tmp_dir,
|
||||
tmp_dir.dvc_gen({"foo": "foo", "bar": "bar"})
|
||||
|
||||
os.remove("foo")
|
||||
getattr(dvc.odb.local.fs, link)(
|
||||
getattr(dvc.cache.local.fs, link)(
|
||||
(tmp_dir / "bar").fs_path, (tmp_dir / "foo").fs_path
|
||||
)
|
||||
|
||||
dvc.odb.local.cache_types = [new_link]
|
||||
dvc.cache.local.cache_types = [new_link]
|
||||
|
||||
dvc.add("foo")
|
||||
|
||||
@@ -650,7 +650,7 @@ def test_should_relink_on_repeated_add(link, new_link, link_test_func, tmp_dir,
|
||||
|
||||
@pytest.mark.parametrize("link", ["hardlink", "symlink", "copy"])
|
||||
def test_should_protect_on_repeated_add(link, tmp_dir, dvc):
|
||||
dvc.odb.local.cache_types = [link]
|
||||
dvc.cache.local.cache_types = [link]
|
||||
|
||||
tmp_dir.dvc_gen({"foo": "foo"})
|
||||
|
||||
@@ -709,7 +709,7 @@ def test_not_raises_on_re_add(tmp_dir, dvc):
|
||||
@pytest.mark.parametrize("link", ["hardlink", "symlink", "copy"])
|
||||
def test_add_empty_files(tmp_dir, dvc, link):
|
||||
file = "foo"
|
||||
dvc.odb.local.cache_types = [link]
|
||||
dvc.cache.local.cache_types = [link]
|
||||
stages = tmp_dir.dvc_gen(file, "")
|
||||
|
||||
assert (tmp_dir / file).exists()
|
||||
@@ -718,7 +718,7 @@ def test_add_empty_files(tmp_dir, dvc, link):
|
||||
|
||||
|
||||
def test_add_optimization_for_hardlink_on_empty_files(tmp_dir, dvc, mocker):
|
||||
dvc.odb.local.cache_types = ["hardlink"]
|
||||
dvc.cache.local.cache_types = ["hardlink"]
|
||||
tmp_dir.gen({"foo": "", "bar": "", "lorem": "lorem", "ipsum": "ipsum"})
|
||||
m = mocker.spy(LocalFileSystem, "is_hardlink")
|
||||
stages = dvc.add(["foo", "bar", "lorem", "ipsum"])
|
||||
|
||||
@@ -105,9 +105,9 @@ def test_checkout_corrupted_cache_dir(tmp_dir, dvc):
|
||||
|
||||
# NOTE: modifying cache file for one of the files inside the directory
|
||||
# to check if dvc will detect that the cache is corrupted.
|
||||
obj = load(dvc.odb.local, out.hash_info)
|
||||
obj = load(dvc.cache.local, out.hash_info)
|
||||
_, _, entry_oid = list(obj)[0]
|
||||
cache = dvc.odb.local.oid_to_path(entry_oid.value)
|
||||
cache = dvc.cache.local.oid_to_path(entry_oid.value)
|
||||
|
||||
os.chmod(cache, 0o644)
|
||||
with open(cache, "w+", encoding="utf-8") as fobj:
|
||||
@@ -161,7 +161,7 @@ class TestCheckoutCleanWorkingDir:
|
||||
|
||||
def test_checkout_selective_remove(tmp_dir, dvc):
|
||||
# Use copy to test for changes in the inodes
|
||||
dvc.odb.local.cache_types = ["copy"]
|
||||
dvc.cache.local.cache_types = ["copy"]
|
||||
tmp_dir.dvc_gen({"data": {"foo": "foo", "bar": "bar"}})
|
||||
|
||||
foo_inode = system.inode(os.path.join("data", "foo"))
|
||||
@@ -357,7 +357,7 @@ def test_checkout_moved_cache_dir_with_symlinks(tmp_dir, dvc):
|
||||
assert system.is_symlink(os.path.join("data", "file"))
|
||||
old_data_link = os.path.realpath(os.path.join("data", "file"))
|
||||
|
||||
old_cache_dir = dvc.odb.local.path
|
||||
old_cache_dir = dvc.cache.local.path
|
||||
new_cache_dir = old_cache_dir + "_new"
|
||||
os.rename(old_cache_dir, new_cache_dir)
|
||||
|
||||
@@ -395,7 +395,7 @@ def test_checkout_no_checksum(tmp_dir, dvc):
|
||||
[("hardlink", system.is_hardlink), ("symlink", system.is_symlink)],
|
||||
)
|
||||
def test_checkout_relink(tmp_dir, dvc, link, link_test_func):
|
||||
dvc.odb.local.cache_types = [link]
|
||||
dvc.cache.local.cache_types = [link]
|
||||
|
||||
tmp_dir.dvc_gen({"dir": {"data": "text"}})
|
||||
dvc.unprotect("dir/data")
|
||||
@@ -408,7 +408,7 @@ def test_checkout_relink(tmp_dir, dvc, link, link_test_func):
|
||||
|
||||
@pytest.mark.parametrize("link", ["hardlink", "symlink", "copy"])
|
||||
def test_checkout_relink_protected(tmp_dir, dvc, link):
|
||||
dvc.odb.local.cache_types = [link]
|
||||
dvc.cache.local.cache_types = [link]
|
||||
|
||||
tmp_dir.dvc_gen("foo", "foo")
|
||||
dvc.unprotect("foo")
|
||||
@@ -595,7 +595,7 @@ def test_checkout_with_relink_existing(tmp_dir, dvc, link):
|
||||
(tmp_dir / "foo").unlink()
|
||||
|
||||
tmp_dir.dvc_gen("bar", "bar")
|
||||
dvc.odb.local.cache_types = [link]
|
||||
dvc.cache.local.cache_types = [link]
|
||||
|
||||
stats = dvc.checkout(relink=True)
|
||||
assert stats == {**empty_checkout, "added": ["foo"]}
|
||||
|
||||
@@ -46,7 +46,7 @@ def test_cloud_cli(tmp_dir, dvc, remote, mocker):
|
||||
_kwargs["jobs"] == jobs for (_args, _kwargs) in oids_exist.call_args_list
|
||||
)
|
||||
|
||||
dvc.odb.local.clear()
|
||||
dvc.cache.local.clear()
|
||||
oids_exist.reset_mock()
|
||||
|
||||
assert main(["fetch", *args]) == 0
|
||||
@@ -86,7 +86,7 @@ def test_cloud_cli(tmp_dir, dvc, remote, mocker):
|
||||
assert main(["gc", "-cw", "-f", *args]) == 0
|
||||
assert _list_oids_traverse.called
|
||||
assert all(_kwargs["jobs"] == 2 for (_args, _kwargs) in oids_exist.call_args_list)
|
||||
shutil.move(dvc.odb.local.path, dvc.odb.local.path + ".back")
|
||||
shutil.move(dvc.cache.local.path, dvc.cache.local.path + ".back")
|
||||
|
||||
assert main(["fetch", *args]) == 0
|
||||
|
||||
@@ -155,7 +155,7 @@ def test_missing_cache(tmp_dir, dvc, local_remote, caplog):
|
||||
tmp_dir.dvc_gen({"foo": "foo", "bar": "bar"})
|
||||
|
||||
# purge cache
|
||||
dvc.odb.local.clear()
|
||||
dvc.cache.local.clear()
|
||||
|
||||
header = (
|
||||
"Some of the cache files do not exist "
|
||||
@@ -194,7 +194,7 @@ def test_verify_hashes(tmp_dir, scm, dvc, mocker, tmp_path_factory, local_remote
|
||||
# remove artifacts and cache to trigger fetching
|
||||
remove("file")
|
||||
remove("dir")
|
||||
dvc.odb.local.clear()
|
||||
dvc.cache.local.clear()
|
||||
|
||||
hash_spy = mocker.spy(dvc_data.hashfile.hash, "file_md5")
|
||||
|
||||
@@ -202,7 +202,7 @@ def test_verify_hashes(tmp_dir, scm, dvc, mocker, tmp_path_factory, local_remote
|
||||
assert hash_spy.call_count == 0
|
||||
|
||||
# Removing cache will invalidate existing state entries
|
||||
dvc.odb.local.clear()
|
||||
dvc.cache.local.clear()
|
||||
|
||||
dvc.config["remote"]["upstream"]["verify"] = True
|
||||
|
||||
@@ -224,9 +224,9 @@ def test_pull_git_imports(tmp_dir, dvc, scm, erepo):
|
||||
|
||||
assert dvc.pull()["fetched"] == 0
|
||||
|
||||
for item in ["foo", "new_dir", dvc.odb.local.path]:
|
||||
for item in ["foo", "new_dir", dvc.cache.local.path]:
|
||||
remove(item)
|
||||
os.makedirs(dvc.odb.local.path, exist_ok=True)
|
||||
os.makedirs(dvc.cache.local.path, exist_ok=True)
|
||||
clean_repos()
|
||||
|
||||
assert dvc.pull(force=True)["fetched"] == 3
|
||||
@@ -295,7 +295,7 @@ def test_pull_external_dvc_imports_mixed(tmp_dir, dvc, scm, erepo_dir, local_rem
|
||||
|
||||
def clean(outs, dvc=None):
|
||||
if dvc:
|
||||
dvc.odb.local.clear()
|
||||
dvc.cache.local.clear()
|
||||
for path in outs:
|
||||
remove(path)
|
||||
if dvc:
|
||||
@@ -471,11 +471,11 @@ def test_push_pull_fetch_pipeline_stages(tmp_dir, dvc, run_copy, local_remote):
|
||||
|
||||
dvc.pull("copy-foo-bar")
|
||||
assert (tmp_dir / "bar").exists()
|
||||
assert len(recurse_list_dir(dvc.odb.local.path)) == 2
|
||||
assert len(recurse_list_dir(dvc.cache.local.path)) == 2
|
||||
clean(["bar"], dvc)
|
||||
|
||||
dvc.fetch("copy-foo-bar")
|
||||
assert len(recurse_list_dir(dvc.odb.local.path)) == 2
|
||||
assert len(recurse_list_dir(dvc.cache.local.path)) == 2
|
||||
|
||||
|
||||
def test_pull_partial(tmp_dir, dvc, local_remote):
|
||||
@@ -521,7 +521,7 @@ def test_output_remote(tmp_dir, dvc, make_remote):
|
||||
|
||||
dvc.pull()
|
||||
|
||||
assert set(dvc.odb.local.all()) == {
|
||||
assert set(dvc.cache.local.all()) == {
|
||||
"37b51d194a7513e45b56f6524f2d51f2",
|
||||
"acbd18db4cc2f85cedef654fccc4a4d8",
|
||||
"f97c5d29941bfb1b2fdab0874906ab82",
|
||||
@@ -554,7 +554,7 @@ def test_target_remote(tmp_dir, dvc, make_remote):
|
||||
|
||||
dvc.pull(remote="myremote")
|
||||
|
||||
assert set(dvc.odb.local.all()) == {
|
||||
assert set(dvc.cache.local.all()) == {
|
||||
"acbd18db4cc2f85cedef654fccc4a4d8",
|
||||
"f97c5d29941bfb1b2fdab0874906ab82",
|
||||
"6b18131dc289fd37006705affe961ef8.dir",
|
||||
|
||||
@@ -234,7 +234,7 @@ def test_untracked_newly_added_files(M, tmp_dir, dvc, scm):
|
||||
def test_missing_cache_workspace_exists(M, tmp_dir, dvc, scm):
|
||||
tmp_dir.dvc_gen({"dir": {"foo": "foo", "bar": "bar"}})
|
||||
tmp_dir.dvc_gen("foobar", "foobar")
|
||||
remove(dvc.odb.repo.path)
|
||||
remove(dvc.cache.repo.path)
|
||||
|
||||
assert dvc.data_status(untracked_files="all") == {
|
||||
**EMPTY_STATUS,
|
||||
@@ -260,7 +260,7 @@ def test_missing_cache_workspace_exists(M, tmp_dir, dvc, scm):
|
||||
def test_missing_cache_missing_workspace(M, tmp_dir, dvc, scm):
|
||||
tmp_dir.dvc_gen({"dir": {"foo": "foo", "bar": "bar"}})
|
||||
tmp_dir.dvc_gen("foobar", "foobar")
|
||||
for path in [dvc.odb.repo.path, "dir", "foobar"]:
|
||||
for path in [dvc.cache.repo.path, "dir", "foobar"]:
|
||||
remove(path)
|
||||
|
||||
assert dvc.data_status(untracked_files="all") == {
|
||||
@@ -285,7 +285,7 @@ def test_missing_cache_missing_workspace(M, tmp_dir, dvc, scm):
|
||||
def test_git_committed_missing_cache_workspace_exists(M, tmp_dir, dvc, scm):
|
||||
tmp_dir.dvc_gen({"dir": {"foo": "foo", "bar": "bar"}}, commit="add dir")
|
||||
tmp_dir.dvc_gen("foobar", "foobar", commit="add foobar")
|
||||
remove(dvc.odb.local.path)
|
||||
remove(dvc.cache.local.path)
|
||||
|
||||
assert dvc.data_status(untracked_files="all") == {
|
||||
**EMPTY_STATUS,
|
||||
@@ -308,7 +308,7 @@ def test_git_committed_missing_cache_workspace_exists(M, tmp_dir, dvc, scm):
|
||||
def test_git_committed_missing_cache_missing_workspace(M, tmp_dir, dvc, scm):
|
||||
tmp_dir.dvc_gen({"dir": {"foo": "foo", "bar": "bar"}}, commit="add dir")
|
||||
tmp_dir.dvc_gen("foobar", "foobar", commit="add foobar")
|
||||
for path in [dvc.odb.repo.path, "dir", "foobar"]:
|
||||
for path in [dvc.cache.repo.path, "dir", "foobar"]:
|
||||
remove(path)
|
||||
|
||||
assert dvc.data_status(untracked_files="all") == {
|
||||
@@ -330,7 +330,7 @@ def test_partial_missing_cache(M, tmp_dir, dvc, scm):
|
||||
tmp_dir.dvc_gen({"dir": {"foo": "foo", "bar": "bar"}})
|
||||
|
||||
# remove "foo" from cache
|
||||
odb = dvc.odb.repo
|
||||
odb = dvc.cache.repo
|
||||
odb.fs.rm(odb.oid_to_path("acbd18db4cc2f85cedef654fccc4a4d8"))
|
||||
|
||||
assert dvc.data_status() == {
|
||||
@@ -354,7 +354,7 @@ def test_missing_dir_object_from_head(M, tmp_dir, dvc, scm):
|
||||
(stage,) = tmp_dir.dvc_gen({"dir": {"foo": "foo", "bar": "bar"}}, commit="add dir")
|
||||
remove("dir")
|
||||
tmp_dir.dvc_gen({"dir": {"foobar": "foobar"}})
|
||||
odb = dvc.odb.repo
|
||||
odb = dvc.cache.repo
|
||||
odb.fs.rm(odb.oid_to_path(stage.outs[0].hash_info.value))
|
||||
|
||||
assert dvc.data_status() == {
|
||||
@@ -376,7 +376,7 @@ def test_missing_dir_object_from_index(M, tmp_dir, dvc, scm):
|
||||
tmp_dir.dvc_gen({"dir": {"foo": "foo", "bar": "bar"}}, commit="add dir")
|
||||
remove("dir")
|
||||
(stage,) = tmp_dir.dvc_gen({"dir": {"foobar": "foobar"}})
|
||||
odb = dvc.odb.repo
|
||||
odb = dvc.cache.repo
|
||||
odb.fs.rm(odb.oid_to_path(stage.outs[0].hash_info.value))
|
||||
|
||||
assert dvc.data_status() == {
|
||||
|
||||
@@ -250,10 +250,10 @@ def test_diff_no_cache(tmp_dir, scm, dvc):
|
||||
tmp_dir.dvc_gen({"dir": {"file": "modified file content"}}, commit="second")
|
||||
scm.tag("v2")
|
||||
|
||||
remove(dvc.odb.local.path)
|
||||
remove(dvc.cache.local.path)
|
||||
|
||||
# invalidate_dir_info to force cache loading
|
||||
dvc.odb.local._dir_info = {}
|
||||
dvc.cache.local._dir_info = {}
|
||||
|
||||
diff = dvc.diff("v1", "v2")
|
||||
assert diff["added"] == []
|
||||
|
||||
@@ -115,7 +115,7 @@ def test_relative_remote(erepo_dir, tmp_dir):
|
||||
erepo_dir.dvc.push()
|
||||
|
||||
(erepo_dir / "file").unlink()
|
||||
remove(erepo_dir.dvc.odb.local.path)
|
||||
remove(erepo_dir.dvc.cache.local.path)
|
||||
|
||||
url = os.fspath(erepo_dir)
|
||||
|
||||
@@ -195,12 +195,12 @@ def test_subrepos_are_ignored(tmp_dir, erepo_dir):
|
||||
assert (tmp_dir / "out").read_text() == expected_files
|
||||
|
||||
# clear cache to test saving to cache
|
||||
cache_dir = tmp_dir / repo.odb.local.path
|
||||
cache_dir = tmp_dir / repo.cache.local.path
|
||||
remove(cache_dir)
|
||||
os.makedirs(cache_dir)
|
||||
|
||||
staging, _, obj = build(
|
||||
repo.odb.local,
|
||||
repo.cache.local,
|
||||
"dir",
|
||||
repo.dvcfs,
|
||||
"md5",
|
||||
@@ -208,7 +208,7 @@ def test_subrepos_are_ignored(tmp_dir, erepo_dir):
|
||||
)
|
||||
transfer(
|
||||
staging,
|
||||
repo.odb.local,
|
||||
repo.cache.local,
|
||||
{obj.hash_info},
|
||||
shallow=False,
|
||||
hardlink=True,
|
||||
|
||||
+20
-18
@@ -20,7 +20,7 @@ def good_and_bad_cache(tmp_dir, dvc):
|
||||
{"sub": {"data_sub": "data_sub", "data": "data", "тест": "проверка"}},
|
||||
)
|
||||
raw_dir_hash = stage.outs[0].hash_info.as_raw().value
|
||||
odb = dvc.odb.local
|
||||
odb = dvc.cache.local
|
||||
|
||||
bad_cache = {raw_dir_hash}
|
||||
for i in ["123", "234", "345"]:
|
||||
@@ -33,14 +33,14 @@ def good_and_bad_cache(tmp_dir, dvc):
|
||||
|
||||
def test_gc_api(dvc, good_and_bad_cache):
|
||||
dvc.gc(workspace=True)
|
||||
odb = dvc.odb.local
|
||||
odb = dvc.cache.local
|
||||
good_cache, bad_cache = good_and_bad_cache
|
||||
assert set(odb.oids_exist([*good_cache, *bad_cache])) == good_cache
|
||||
|
||||
|
||||
def test_gc_cli(dvc, good_and_bad_cache):
|
||||
assert main(["gc", "-wf"]) == 0
|
||||
odb = dvc.odb.local
|
||||
odb = dvc.cache.local
|
||||
good_cache, bad_cache = good_and_bad_cache
|
||||
assert set(odb.oids_exist([*good_cache, *bad_cache])) == good_cache
|
||||
|
||||
@@ -59,7 +59,7 @@ def test_gc_branches_tags(tmp_dir, dvc, scm):
|
||||
dvc.remove("file.dvc")
|
||||
tmp_dir.dvc_gen("file", "master", commit="trash")
|
||||
|
||||
odb = dvc.odb.local
|
||||
odb = dvc.cache.local
|
||||
assert len(list(odb.all())) == 4
|
||||
|
||||
dvc.gc(all_tags=True, all_branches=True)
|
||||
@@ -76,12 +76,12 @@ def test_gc_multiple_dvc_repos(tmp_dir, scm, dvc, erepo_dir):
|
||||
tmp_dir.dvc_gen("only_in_first", "only in main repo")
|
||||
tmp_dir.dvc_gen("in_both", "in both repos")
|
||||
|
||||
erepo_dir.dvc.odb.local.path = dvc.odb.local.path
|
||||
erepo_dir.dvc.cache.local.path = dvc.cache.local.path
|
||||
with erepo_dir.chdir():
|
||||
erepo_dir.dvc_gen("in_both", "in both repos")
|
||||
erepo_dir.dvc_gen("only_in_second", "only in additional repo")
|
||||
|
||||
odb = dvc.odb.local
|
||||
odb = dvc.cache.local
|
||||
assert len(list(odb.all())) == 3
|
||||
|
||||
dvc.gc(repos=[erepo_dir], workspace=True)
|
||||
@@ -97,11 +97,11 @@ def test_all_commits(tmp_dir, scm, dvc):
|
||||
tmp_dir.dvc_gen("testfile", "modified", commit="modified")
|
||||
tmp_dir.dvc_gen("testfile", "workspace")
|
||||
|
||||
n = _count_files(dvc.odb.local.path)
|
||||
n = _count_files(dvc.cache.local.path)
|
||||
dvc.gc(all_commits=True)
|
||||
|
||||
# Only one uncommitted file should go away
|
||||
assert _count_files(dvc.odb.local.path) == n - 1
|
||||
assert _count_files(dvc.cache.local.path) == n - 1
|
||||
|
||||
|
||||
def test_gc_no_dir_cache(tmp_dir, dvc):
|
||||
@@ -113,9 +113,9 @@ def test_gc_no_dir_cache(tmp_dir, dvc):
|
||||
with pytest.raises(CollectCacheError):
|
||||
dvc.gc(workspace=True)
|
||||
|
||||
assert _count_files(dvc.odb.local.path) == 4
|
||||
assert _count_files(dvc.cache.local.path) == 4
|
||||
dvc.gc(force=True, workspace=True)
|
||||
assert _count_files(dvc.odb.local.path) == 2
|
||||
assert _count_files(dvc.cache.local.path) == 2
|
||||
|
||||
|
||||
def _count_files(path):
|
||||
@@ -240,14 +240,14 @@ def test_gc_not_collect_pipeline_tracked_files(tmp_dir, dvc, run_copy):
|
||||
|
||||
run_copy("foo", "foo2", name="copy")
|
||||
shutil.rmtree(dvc.stage_cache.cache_dir)
|
||||
assert _count_files(dvc.odb.local.path) == 1
|
||||
assert _count_files(dvc.cache.local.path) == 1
|
||||
dvc.gc(workspace=True, force=True)
|
||||
assert _count_files(dvc.odb.local.path) == 1
|
||||
assert _count_files(dvc.cache.local.path) == 1
|
||||
|
||||
# remove pipeline file and lockfile and check
|
||||
load_file(dvc, PROJECT_FILE).remove(force=True)
|
||||
dvc.gc(workspace=True, force=True)
|
||||
assert _count_files(dvc.odb.local.path) == 0
|
||||
assert _count_files(dvc.cache.local.path) == 0
|
||||
|
||||
|
||||
def test_gc_external_output(tmp_dir, dvc, workspace):
|
||||
@@ -328,13 +328,15 @@ def test_date(tmp_dir, scm, dvc):
|
||||
|
||||
dvc.gc(commit_date=datestamp)
|
||||
|
||||
assert _count_files(dvc.odb.local.path) == 1
|
||||
assert dvc.odb.local.exists("9ae73c65f418e6f79ceb4f0e4a4b98d5") # "modified"
|
||||
assert _count_files(dvc.cache.local.path) == 1
|
||||
assert dvc.cache.local.exists("9ae73c65f418e6f79ceb4f0e4a4b98d5") # "modified"
|
||||
|
||||
tmp_dir.dvc_gen("testfile", "modified, again", commit="modify")
|
||||
|
||||
datestamp = (now.date() - datetime.timedelta(days=1)).isoformat()
|
||||
dvc.gc(commit_date=datestamp)
|
||||
assert _count_files(dvc.odb.local.path) == 2
|
||||
assert dvc.odb.local.exists("9ae73c65f418e6f79ceb4f0e4a4b98d5")
|
||||
assert dvc.odb.local.exists("3bcf3b1be3e794a97a5a6b93a005784c") # "modified, again"
|
||||
assert _count_files(dvc.cache.local.path) == 2
|
||||
assert dvc.cache.local.exists("9ae73c65f418e6f79ceb4f0e4a4b98d5")
|
||||
assert dvc.cache.local.exists(
|
||||
"3bcf3b1be3e794a97a5a6b93a005784c"
|
||||
) # "modified, again"
|
||||
|
||||
@@ -3,9 +3,9 @@ import os
|
||||
|
||||
import pytest
|
||||
|
||||
from dvc.cachemgr import CacheManager
|
||||
from dvc.cli import main
|
||||
from dvc.fs import system
|
||||
from dvc.odbmgr import ODBManager
|
||||
from dvc.repo import Repo
|
||||
from dvc.repo.get import GetDVCFileError
|
||||
from dvc.testing.tmp_dir import make_subrepo
|
||||
@@ -76,7 +76,7 @@ def test_cache_type_is_properly_overridden(tmp_dir, erepo_dir):
|
||||
with erepo_dir.chdir():
|
||||
with erepo_dir.dvc.config.edit() as conf:
|
||||
conf["cache"]["type"] = "symlink"
|
||||
erepo_dir.dvc.odb = ODBManager(erepo_dir.dvc)
|
||||
erepo_dir.dvc.cache = CacheManager(erepo_dir.dvc)
|
||||
erepo_dir.scm_add(
|
||||
[erepo_dir.dvc.config.files["repo"]], "set cache type to symlinks"
|
||||
)
|
||||
|
||||
@@ -477,7 +477,7 @@ def test_pull_ignore(tmp_dir, dvc, local_cloud):
|
||||
foo_path.unlink()
|
||||
assert not foo_path.exists()
|
||||
|
||||
dvc.odb.local.clear()
|
||||
dvc.cache.local.clear()
|
||||
dvc.pull()
|
||||
|
||||
assert foo_path.exists()
|
||||
|
||||
+10
-10
@@ -5,11 +5,11 @@ import pytest
|
||||
from funcy import first
|
||||
|
||||
from dvc.annotations import Annotation
|
||||
from dvc.cachemgr import CacheManager
|
||||
from dvc.config import NoRemoteError
|
||||
from dvc.dvcfile import load_file
|
||||
from dvc.exceptions import DownloadError, PathMissingError
|
||||
from dvc.fs import system
|
||||
from dvc.odbmgr import ODBManager
|
||||
from dvc.scm import Git
|
||||
from dvc.stage.exceptions import StagePathNotFoundError
|
||||
from dvc.testing.tmp_dir import make_subrepo
|
||||
@@ -272,7 +272,7 @@ def test_cache_type_is_properly_overridden(tmp_dir, scm, dvc, erepo_dir):
|
||||
with erepo_dir.chdir():
|
||||
with erepo_dir.dvc.config.edit() as conf:
|
||||
conf["cache"]["type"] = "symlink"
|
||||
erepo_dir.dvc.odb = ODBManager(erepo_dir.dvc)
|
||||
erepo_dir.dvc.cache = CacheManager(erepo_dir.dvc)
|
||||
erepo_dir.scm_add(
|
||||
[erepo_dir.dvc.config.files["repo"]],
|
||||
"set source repo cache type to symlink",
|
||||
@@ -294,7 +294,7 @@ def test_pull_imported_directory_stage(tmp_dir, dvc, erepo_dir):
|
||||
dvc.imp(os.fspath(erepo_dir), "dir", "dir_imported")
|
||||
|
||||
remove("dir_imported")
|
||||
dvc.odb.local.clear()
|
||||
dvc.cache.local.clear()
|
||||
|
||||
dvc.pull(["dir_imported.dvc"])
|
||||
|
||||
@@ -308,7 +308,7 @@ def test_pull_wildcard_imported_directory_stage(tmp_dir, dvc, erepo_dir):
|
||||
dvc.imp(os.fspath(erepo_dir), "dir123", "dir_imported123")
|
||||
|
||||
remove("dir_imported123")
|
||||
dvc.odb.local.clear()
|
||||
dvc.cache.local.clear()
|
||||
|
||||
dvc.pull(["dir_imported*.dvc"], glob=True)
|
||||
|
||||
@@ -536,7 +536,7 @@ def test_pull_imported_stage_from_subrepos(tmp_dir, dvc, erepo_dir, is_dvc, file
|
||||
dvc.imp(os.fspath(erepo_dir), path, out="out")
|
||||
|
||||
# clean everything
|
||||
dvc.odb.local.clear()
|
||||
dvc.cache.local.clear()
|
||||
remove("out")
|
||||
|
||||
stats = dvc.pull(["out.dvc"])
|
||||
@@ -606,7 +606,7 @@ def test_chained_import(tmp_dir, dvc, make_tmp_dir, erepo_dir, local_cloud):
|
||||
with erepo_dir.chdir():
|
||||
erepo_dir.dvc_gen({"dir": {"foo": "foo", "bar": "bar"}}, commit="init")
|
||||
erepo_dir.dvc.push()
|
||||
remove(erepo_dir.dvc.odb.local.path)
|
||||
remove(erepo_dir.dvc.cache.local.path)
|
||||
remove(os.fspath(erepo_dir / "dir"))
|
||||
|
||||
erepo2 = make_tmp_dir("erepo2", scm=True, dvc=True)
|
||||
@@ -614,7 +614,7 @@ def test_chained_import(tmp_dir, dvc, make_tmp_dir, erepo_dir, local_cloud):
|
||||
erepo2.dvc.imp(os.fspath(erepo_dir), "dir")
|
||||
erepo2.scm.add("dir.dvc")
|
||||
erepo2.scm.commit("import")
|
||||
remove(erepo2.dvc.odb.local.path)
|
||||
remove(erepo2.dvc.cache.local.path)
|
||||
remove(os.fspath(erepo2 / "dir"))
|
||||
|
||||
dvc.imp(os.fspath(erepo2), "dir", "dir_imported")
|
||||
@@ -622,14 +622,14 @@ def test_chained_import(tmp_dir, dvc, make_tmp_dir, erepo_dir, local_cloud):
|
||||
assert (dst / "foo").read_text() == "foo"
|
||||
assert (dst / "bar").read_text() == "bar"
|
||||
|
||||
dvc.odb.local.clear()
|
||||
dvc.cache.local.clear()
|
||||
remove("dir_imported")
|
||||
|
||||
# pulled objects should come from the original upstream repo's remote,
|
||||
# no cache or remote should be needed from the intermediate repo
|
||||
dvc.pull(["dir_imported.dvc"])
|
||||
assert not os.path.exists(erepo_dir.dvc.odb.local.path)
|
||||
assert not os.path.exists(erepo2.dvc.odb.local.path)
|
||||
assert not os.path.exists(erepo_dir.dvc.cache.local.path)
|
||||
assert not os.path.exists(erepo2.dvc.cache.local.path)
|
||||
assert (dst / "foo").read_text() == "foo"
|
||||
assert (dst / "bar").read_text() == "bar"
|
||||
|
||||
|
||||
+17
-17
@@ -4,8 +4,8 @@ import stat
|
||||
import configobj
|
||||
import pytest
|
||||
|
||||
from dvc.cachemgr import CacheManager
|
||||
from dvc.cli import main
|
||||
from dvc.odbmgr import ODBManager
|
||||
from dvc.utils import relpath
|
||||
from dvc_data.hashfile.hash_info import HashInfo
|
||||
from dvc_objects.errors import ObjectFormatError
|
||||
@@ -15,12 +15,12 @@ def test_cache(tmp_dir, dvc):
|
||||
cache1_md5 = "123"
|
||||
cache2_md5 = "234"
|
||||
cache1 = os.path.join(
|
||||
dvc.odb.local.path,
|
||||
dvc.cache.local.path,
|
||||
cache1_md5[0:2],
|
||||
cache1_md5[2:],
|
||||
)
|
||||
cache2 = os.path.join(
|
||||
dvc.odb.local.path,
|
||||
dvc.cache.local.path,
|
||||
cache2_md5[0:2],
|
||||
cache2_md5[2:],
|
||||
)
|
||||
@@ -29,7 +29,7 @@ def test_cache(tmp_dir, dvc):
|
||||
assert os.path.exists(cache1)
|
||||
assert os.path.exists(cache2)
|
||||
|
||||
odb = ODBManager(dvc)
|
||||
odb = CacheManager(dvc)
|
||||
|
||||
md5_list = list(odb.local.all())
|
||||
assert len(md5_list) == 2
|
||||
@@ -46,16 +46,16 @@ def test_cache_load_bad_dir_cache(tmp_dir, dvc):
|
||||
from dvc_data.hashfile import load
|
||||
|
||||
dir_hash = "123.dir"
|
||||
fname = os.fspath(dvc.odb.local.oid_to_path(dir_hash))
|
||||
fname = os.fspath(dvc.cache.local.oid_to_path(dir_hash))
|
||||
tmp_dir.gen({fname: "<clearly>not,json"})
|
||||
with pytest.raises(ObjectFormatError):
|
||||
load(dvc.odb.local, HashInfo("md5", dir_hash))
|
||||
load(dvc.cache.local, HashInfo("md5", dir_hash))
|
||||
|
||||
dir_hash = "234.dir"
|
||||
fname = os.fspath(dvc.odb.local.oid_to_path(dir_hash))
|
||||
fname = os.fspath(dvc.cache.local.oid_to_path(dir_hash))
|
||||
tmp_dir.gen({fname: '{"a": "b"}'})
|
||||
with pytest.raises(ObjectFormatError):
|
||||
load(dvc.odb.local, HashInfo("md5", dir_hash))
|
||||
load(dvc.cache.local, HashInfo("md5", dir_hash))
|
||||
|
||||
|
||||
def test_external_cache_dir(tmp_dir, dvc, make_tmp_dir):
|
||||
@@ -63,8 +63,8 @@ def test_external_cache_dir(tmp_dir, dvc, make_tmp_dir):
|
||||
|
||||
with dvc.config.edit() as conf:
|
||||
conf["cache"]["dir"] = cache_dir.fs_path
|
||||
assert not os.path.exists(dvc.odb.local.path)
|
||||
dvc.odb = ODBManager(dvc)
|
||||
assert not os.path.exists(dvc.cache.local.path)
|
||||
dvc.cache = CacheManager(dvc)
|
||||
|
||||
tmp_dir.dvc_gen({"foo": "foo"})
|
||||
|
||||
@@ -87,9 +87,9 @@ def test_remote_cache_references(tmp_dir, dvc):
|
||||
conf["remote"]["cache"] = {"url": "remote://storage/tmp"}
|
||||
conf["cache"]["ssh"] = "cache"
|
||||
|
||||
dvc.odb = ODBManager(dvc)
|
||||
dvc.cache = CacheManager(dvc)
|
||||
|
||||
assert dvc.odb.ssh.path == "/tmp"
|
||||
assert dvc.cache.ssh.path == "/tmp"
|
||||
|
||||
|
||||
def test_shared_cache_dir(tmp_dir):
|
||||
@@ -126,7 +126,7 @@ def test_shared_cache_dir(tmp_dir):
|
||||
def test_cache_link_type(tmp_dir, scm, dvc):
|
||||
with dvc.config.edit() as conf:
|
||||
conf["cache"]["type"] = "reflink,copy"
|
||||
dvc.odb = ODBManager(dvc)
|
||||
dvc.cache = CacheManager(dvc)
|
||||
|
||||
stages = tmp_dir.dvc_gen({"foo": "foo"})
|
||||
assert len(stages) == 1
|
||||
@@ -154,7 +154,7 @@ def test_cmd_cache_relative_path(tmp_dir, scm, dvc, make_tmp_dir):
|
||||
assert ret == 0
|
||||
|
||||
dvc.config.load()
|
||||
dvc.odb = ODBManager(dvc)
|
||||
dvc.cache = CacheManager(dvc)
|
||||
|
||||
# NOTE: we are in the repo's root and config is in .dvc/, so
|
||||
# dir path written to config should be just one level above.
|
||||
@@ -170,7 +170,7 @@ def test_cmd_cache_relative_path(tmp_dir, scm, dvc, make_tmp_dir):
|
||||
|
||||
|
||||
def test_default_cache_type(dvc):
|
||||
assert dvc.odb.local.cache_types == ["reflink", "copy"]
|
||||
assert dvc.cache.local.cache_types == ["reflink", "copy"]
|
||||
|
||||
|
||||
@pytest.mark.skipif(os.name == "nt", reason="Not supported for Windows.")
|
||||
@@ -181,8 +181,8 @@ def test_shared_cache(tmp_dir, dvc, group):
|
||||
if group:
|
||||
with dvc.config.edit() as conf:
|
||||
conf["cache"].update({"shared": "group"})
|
||||
dvc.odb = ODBManager(dvc)
|
||||
cache_dir = dvc.odb.local.path
|
||||
dvc.cache = CacheManager(dvc)
|
||||
cache_dir = dvc.cache.local.path
|
||||
|
||||
assert not os.path.exists(cache_dir)
|
||||
|
||||
|
||||
@@ -139,16 +139,16 @@ def test_dir_hash_should_be_key_order_agnostic(tmp_dir, dvc):
|
||||
tree = Tree.from_list([{"relpath": "1", "md5": "1"}, {"relpath": "2", "md5": "2"}])
|
||||
tree.digest()
|
||||
with patch("dvc_data.hashfile.build._build_tree", return_value=(None, tree)):
|
||||
_, _, obj = build(dvc.odb.local, path, dvc.odb.local.fs, "md5")
|
||||
_, _, obj = build(dvc.cache.local, path, dvc.cache.local.fs, "md5")
|
||||
hash1 = obj.hash_info
|
||||
|
||||
# remove the raw dir obj to force building the tree on the next build call
|
||||
dvc.odb.local.fs.remove(dvc.odb.local.oid_to_path(hash1.as_raw().value))
|
||||
dvc.cache.local.fs.remove(dvc.cache.local.oid_to_path(hash1.as_raw().value))
|
||||
|
||||
tree = Tree.from_list([{"md5": "1", "relpath": "1"}, {"md5": "2", "relpath": "2"}])
|
||||
tree.digest()
|
||||
with patch("dvc_data.hashfile.build._build_tree", return_value=(None, tree)):
|
||||
_, _, obj = build(dvc.odb.local, path, dvc.odb.local.fs, "md5")
|
||||
_, _, obj = build(dvc.cache.local, path, dvc.cache.local.fs, "md5")
|
||||
hash2 = obj.hash_info
|
||||
|
||||
assert hash1 == hash2
|
||||
@@ -201,7 +201,7 @@ def test_partial_push_n_pull( # noqa: C901
|
||||
|
||||
# Push everything and delete local cache
|
||||
dvc.push()
|
||||
dvc.odb.local.clear()
|
||||
dvc.cache.local.clear()
|
||||
|
||||
baz._collect_used_dir_cache()
|
||||
|
||||
@@ -263,7 +263,7 @@ def test_external_dir_resource_on_no_cache(tmp_dir, dvc, tmp_path_factory):
|
||||
external_dir = tmp_path_factory.mktemp("external_dir")
|
||||
file = external_dir / "file"
|
||||
|
||||
dvc.odb.local = None
|
||||
dvc.cache.local = None
|
||||
with pytest.raises(RemoteCacheRequiredError):
|
||||
dvc.run(
|
||||
cmd=f"echo content > {file}",
|
||||
@@ -426,7 +426,7 @@ def test_push_incomplete_dir(tmp_dir, dvc, mocker, local_remote):
|
||||
(stage,) = tmp_dir.dvc_gen({"dir": {"foo": "foo", "bar": "bar"}})
|
||||
remote_odb = dvc.cloud.get_remote_odb("upstream")
|
||||
|
||||
odb = dvc.odb.local
|
||||
odb = dvc.cache.local
|
||||
out = stage.outs[0]
|
||||
file_objs = [entry_obj for _, _, entry_obj in out.obj]
|
||||
|
||||
|
||||
@@ -53,10 +53,10 @@ def test_remove_non_existent_file(tmp_dir, dvc):
|
||||
|
||||
def test_remove_broken_symlink(tmp_dir, dvc):
|
||||
tmp_dir.gen("foo", "foo")
|
||||
dvc.odb.local.cache_types = ["symlink"]
|
||||
dvc.cache.local.cache_types = ["symlink"]
|
||||
|
||||
(stage,) = dvc.add("foo")
|
||||
remove(dvc.odb.local.path)
|
||||
remove(dvc.cache.local.path)
|
||||
assert system.is_symlink("foo")
|
||||
|
||||
with pytest.raises(ObjectDBError):
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
from dvc.cachemgr import CacheManager
|
||||
from dvc.dvcfile import LOCK_FILE, PROJECT_FILE
|
||||
from dvc.fs import system
|
||||
from dvc.odbmgr import ODBManager
|
||||
|
||||
|
||||
def test_destroy(tmp_dir, dvc, run_copy):
|
||||
dvc.config["cache"]["type"] = ["symlink"]
|
||||
dvc.odb = ODBManager(dvc)
|
||||
dvc.cache = CacheManager(dvc)
|
||||
|
||||
tmp_dir.dvc_gen("file", "text")
|
||||
tmp_dir.dvc_gen({"dir": {"file": "lorem", "subdir/file": "ipsum"}})
|
||||
|
||||
@@ -837,11 +837,11 @@ def test_repro_no_commit(tmp_dir, dvc, copy_script, run_stage):
|
||||
cmd="python copy.py foo file1",
|
||||
name="run1",
|
||||
)
|
||||
remove(dvc.odb.local.path)
|
||||
remove(dvc.cache.local.path)
|
||||
ret = main(["repro", stage.addressing, "--no-commit"])
|
||||
assert ret == 0
|
||||
# run-cache should be skipped if `-no-commit`.
|
||||
assert not os.path.isdir(dvc.odb.local.path)
|
||||
assert not os.path.isdir(dvc.cache.local.path)
|
||||
|
||||
|
||||
class TestReproAlreadyCached:
|
||||
|
||||
@@ -682,12 +682,12 @@ def test_run_commit(dvc):
|
||||
)
|
||||
assert ret == 0
|
||||
assert os.path.isfile(fname)
|
||||
assert not os.path.exists(dvc.odb.local.path)
|
||||
assert not os.path.exists(dvc.cache.local.path)
|
||||
|
||||
ret = main(["commit", fname + ".dvc"])
|
||||
assert ret == 0
|
||||
assert os.path.isfile(fname)
|
||||
assert len(list(dvc.odb.local.all())) == 1
|
||||
assert len(list(dvc.cache.local.all())) == 1
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -789,7 +789,7 @@ def test_should_not_checkout_upon_corrupted_local_hardlink_cache(
|
||||
mocker, tmp_dir, dvc, copy_script
|
||||
):
|
||||
tmp_dir.gen("foo", "foo")
|
||||
dvc.odb.local.cache_types = ["hardlink"]
|
||||
dvc.cache.local.cache_types = ["hardlink"]
|
||||
|
||||
stage = dvc.run(
|
||||
deps=["foo"],
|
||||
|
||||
@@ -4,7 +4,7 @@ import os
|
||||
def test_unprotect(tmp_dir, dvc):
|
||||
tmp_dir.gen("foo", "foo")
|
||||
|
||||
dvc.odb.local.cache_types = ["hardlink"]
|
||||
dvc.cache.local.cache_types = ["hardlink"]
|
||||
dvc.add("foo")
|
||||
cache = os.path.join(".dvc", "cache", "ac", "bd18db4cc2f85cedef654fccc4a4d8")
|
||||
assert not os.access("foo", os.W_OK)
|
||||
|
||||
Reference in New Issue
Block a user