mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-12-03 07:18:28 +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:
@@ -32,7 +32,7 @@ def test_status_download_optimization(mocker, dvc):
|
||||
|
||||
@pytest.mark.parametrize("link_name", ["hardlink", "symlink"])
|
||||
def test_is_protected(tmp_dir, dvc, link_name):
|
||||
odb = dvc.odb.local
|
||||
odb = dvc.cache.local
|
||||
fs = odb.fs
|
||||
link_method = getattr(fs, link_name)
|
||||
|
||||
@@ -67,7 +67,7 @@ def test_protect_ignore_errors(tmp_dir, dvc, mocker, err):
|
||||
tmp_dir.gen("foo", "foo")
|
||||
|
||||
mock_chmod = mocker.patch("os.chmod", side_effect=OSError(err, "something"))
|
||||
dvc.odb.local.protect("foo")
|
||||
dvc.cache.local.protect("foo")
|
||||
assert mock_chmod.called
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ def test_set_exec_ignore_errors(tmp_dir, dvc, mocker, err):
|
||||
tmp_dir.gen("foo", "foo")
|
||||
|
||||
mock_chmod = mocker.patch("os.chmod", side_effect=OSError(err, "something"))
|
||||
dvc.odb.local.set_exec("foo")
|
||||
dvc.cache.local.set_exec("foo")
|
||||
assert mock_chmod.called
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ def test_staging_file(tmp_dir, dvc):
|
||||
tmp_dir.gen("foo", "foo")
|
||||
fs = LocalFileSystem()
|
||||
|
||||
local_odb = dvc.odb.local
|
||||
local_odb = dvc.cache.local
|
||||
staging_odb, _, obj = build(local_odb, (tmp_dir / "foo").fs_path, fs, "md5")
|
||||
|
||||
assert not local_odb.exists(obj.hash_info.value)
|
||||
@@ -113,7 +113,7 @@ def test_staging_dir(tmp_dir, dvc):
|
||||
|
||||
tmp_dir.gen({"dir": {"foo": "foo", "bar": "bar"}})
|
||||
fs = LocalFileSystem()
|
||||
local_odb = dvc.odb.local
|
||||
local_odb = dvc.cache.local
|
||||
|
||||
staging_odb, _, obj = build(local_odb, (tmp_dir / "dir").fs_path, fs, "md5")
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ def test_open_dirty_hash(tmp_dir, dvc):
|
||||
def test_open_no_remote(tmp_dir, dvc):
|
||||
tmp_dir.dvc_gen("file", "file")
|
||||
(tmp_dir / "file").unlink()
|
||||
remove(dvc.odb.local.path)
|
||||
remove(dvc.cache.local.path)
|
||||
|
||||
fs = DataFileSystem(index=dvc.index.data["repo"])
|
||||
with pytest.raises(FileNotFoundError):
|
||||
@@ -238,11 +238,11 @@ def test_get_hash_granular(tmp_dir, dvc):
|
||||
fs = DataFileSystem(index=dvc.index.data["repo"])
|
||||
subdir = "dir/subdir"
|
||||
assert fs.info(subdir).get("md5") is None
|
||||
_, _, obj = build(dvc.odb.local, subdir, fs, "md5", dry_run=True)
|
||||
_, _, obj = build(dvc.cache.local, subdir, fs, "md5", dry_run=True)
|
||||
assert obj.hash_info == HashInfo("md5", "af314506f1622d107e0ed3f14ec1a3b5.dir")
|
||||
data = posixpath.join(subdir, "data")
|
||||
assert fs.info(data)["md5"] == "8d777f385d3dfec8815d20f7496026dc"
|
||||
_, _, obj = build(dvc.odb.local, data, fs, "md5", dry_run=True)
|
||||
_, _, obj = build(dvc.cache.local, data, fs, "md5", dry_run=True)
|
||||
assert obj.hash_info == HashInfo("md5", "8d777f385d3dfec8815d20f7496026dc")
|
||||
|
||||
|
||||
@@ -253,7 +253,7 @@ def test_get_hash_dirty_file(tmp_dir, dvc):
|
||||
fs = DataFileSystem(index=dvc.index.data["repo"])
|
||||
expected = "8c7dd922ad47494fc02c388e12c00eac"
|
||||
assert fs.info("file").get("md5") == expected
|
||||
_, _, obj = build(dvc.odb.local, "file", fs, "md5", dry_run=True)
|
||||
_, _, obj = build(dvc.cache.local, "file", fs, "md5", dry_run=True)
|
||||
assert obj.hash_info == HashInfo("md5", expected)
|
||||
|
||||
|
||||
@@ -264,5 +264,5 @@ def test_get_hash_dirty_dir(tmp_dir, dvc):
|
||||
fs = DataFileSystem(index=dvc.index.data["repo"])
|
||||
expected = "5ea40360f5b4ec688df672a4db9c17d1.dir"
|
||||
assert fs.info("dir").get("md5") == expected
|
||||
_, _, obj = build(dvc.odb.local, "dir", fs, "md5", dry_run=True)
|
||||
_, _, obj = build(dvc.cache.local, "dir", fs, "md5", dry_run=True)
|
||||
assert obj.hash_info == HashInfo("md5", expected)
|
||||
|
||||
@@ -493,7 +493,7 @@ def test_get_hash_cached_file(tmp_dir, dvc, mocker):
|
||||
fs = DVCFileSystem(repo=dvc)
|
||||
expected = "acbd18db4cc2f85cedef654fccc4a4d8"
|
||||
assert fs.info("foo").get("md5") is None
|
||||
_, _, obj = build(dvc.odb.local, "foo", fs, "md5")
|
||||
_, _, obj = build(dvc.cache.local, "foo", fs, "md5")
|
||||
assert obj.hash_info == HashInfo("md5", expected)
|
||||
(tmp_dir / "foo").unlink()
|
||||
assert fs.info("foo")["md5"] == expected
|
||||
@@ -504,12 +504,12 @@ def test_get_hash_cached_dir(tmp_dir, dvc, mocker):
|
||||
fs = DVCFileSystem(repo=dvc)
|
||||
expected = "8761c4e9acad696bee718615e23e22db.dir"
|
||||
assert fs.info("dir").get("md5") is None
|
||||
_, _, obj = build(dvc.odb.local, "dir", fs, "md5")
|
||||
_, _, obj = build(dvc.cache.local, "dir", fs, "md5")
|
||||
assert obj.hash_info == HashInfo("md5", "8761c4e9acad696bee718615e23e22db.dir")
|
||||
|
||||
shutil.rmtree(tmp_dir / "dir")
|
||||
assert fs.info("dir")["md5"] == expected
|
||||
_, _, obj = build(dvc.odb.local, "dir", fs, "md5")
|
||||
_, _, obj = build(dvc.cache.local, "dir", fs, "md5")
|
||||
assert obj.hash_info == HashInfo("md5", "8761c4e9acad696bee718615e23e22db.dir")
|
||||
|
||||
|
||||
@@ -518,10 +518,10 @@ def test_get_hash_cached_granular(tmp_dir, dvc, mocker):
|
||||
fs = DVCFileSystem(repo=dvc)
|
||||
subdir = "dir/subdir"
|
||||
assert fs.info(subdir).get("md5") is None
|
||||
_, _, obj = build(dvc.odb.local, subdir, fs, "md5")
|
||||
_, _, obj = build(dvc.cache.local, subdir, fs, "md5")
|
||||
assert obj.hash_info == HashInfo("md5", "af314506f1622d107e0ed3f14ec1a3b5.dir")
|
||||
assert fs.info(posixpath.join(subdir, "data")).get("md5") is None
|
||||
_, _, obj = build(dvc.odb.local, posixpath.join(subdir, "data"), fs, "md5")
|
||||
_, _, obj = build(dvc.cache.local, posixpath.join(subdir, "data"), fs, "md5")
|
||||
assert obj.hash_info == HashInfo("md5", "8d777f385d3dfec8815d20f7496026dc")
|
||||
(tmp_dir / "dir" / "subdir" / "data").unlink()
|
||||
assert (
|
||||
@@ -543,7 +543,7 @@ def test_get_hash_mixed_dir(tmp_dir, scm, dvc):
|
||||
tmp_dir.scm.commit("add dir")
|
||||
|
||||
fs = DVCFileSystem(repo=dvc)
|
||||
_, _, obj = build(dvc.odb.local, "dir", fs, "md5")
|
||||
_, _, obj = build(dvc.cache.local, "dir", fs, "md5")
|
||||
assert obj.hash_info == HashInfo("md5", "e1d9e8eae5374860ae025ec84cfd85c7.dir")
|
||||
|
||||
|
||||
@@ -561,7 +561,7 @@ def test_get_hash_dirty_file(tmp_dir, dvc):
|
||||
# hash_file(file) should return workspace hash, not DVC cached hash
|
||||
fs = DVCFileSystem(repo=dvc)
|
||||
assert fs.info("file").get("md5") is None
|
||||
staging, _, obj = build(dvc.odb.local, "file", fs, "md5")
|
||||
staging, _, obj = build(dvc.cache.local, "file", fs, "md5")
|
||||
assert obj.hash_info == something_hash_info
|
||||
check(staging, obj)
|
||||
|
||||
@@ -573,7 +573,7 @@ def test_get_hash_dirty_file(tmp_dir, dvc):
|
||||
|
||||
# tmp_dir/file can be built even though it is missing in workspace since
|
||||
# repofs will use the DVC cached hash (and refer to the local cache object)
|
||||
_, _, obj = build(dvc.odb.local, "file", fs, "md5")
|
||||
_, _, obj = build(dvc.cache.local, "file", fs, "md5")
|
||||
assert obj.hash_info == file_hash_info
|
||||
|
||||
|
||||
@@ -582,7 +582,7 @@ def test_get_hash_dirty_dir(tmp_dir, dvc):
|
||||
(tmp_dir / "dir" / "baz").write_text("baz")
|
||||
|
||||
fs = DVCFileSystem(repo=dvc)
|
||||
_, meta, obj = build(dvc.odb.local, "dir", fs, "md5")
|
||||
_, meta, obj = build(dvc.cache.local, "dir", fs, "md5")
|
||||
assert obj.hash_info == HashInfo("md5", "ba75a2162ca9c29acecb7957105a0bc2.dir")
|
||||
assert meta.nfiles == 3
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ def test_remote_missing_dependency_on_dir_pull(tmp_dir, scm, dvc, mocker):
|
||||
conf["core"] = {"remote": "s3"}
|
||||
|
||||
remove("dir")
|
||||
remove(dvc.odb.local.path)
|
||||
remove(dvc.cache.local.path)
|
||||
|
||||
mocker.patch(
|
||||
"dvc.data_cloud.DataCloud.get_remote_odb",
|
||||
|
||||
@@ -146,16 +146,16 @@ def test_stage_cache_wdir(tmp_dir, dvc, mocker):
|
||||
def test_shared_stage_cache(tmp_dir, dvc, run_copy):
|
||||
import stat
|
||||
|
||||
from dvc.odbmgr import ODBManager
|
||||
from dvc.cachemgr import CacheManager
|
||||
|
||||
tmp_dir.gen("foo", "foo")
|
||||
|
||||
with dvc.config.edit() as config:
|
||||
config["cache"]["shared"] = "group"
|
||||
|
||||
dvc.odb = ODBManager(dvc)
|
||||
dvc.cache = CacheManager(dvc)
|
||||
|
||||
assert not os.path.exists(dvc.odb.local.path)
|
||||
assert not os.path.exists(dvc.cache.local.path)
|
||||
|
||||
run_copy("foo", "bar", name="copy-foo-bar")
|
||||
|
||||
@@ -184,7 +184,7 @@ def test_shared_stage_cache(tmp_dir, dvc, run_copy):
|
||||
dir_mode = 0o2775
|
||||
file_mode = 0o664
|
||||
|
||||
assert _mode(dvc.odb.local.path) == dir_mode
|
||||
assert _mode(dvc.cache.local.path) == dir_mode
|
||||
assert _mode(dvc.stage_cache.cache_dir) == dir_mode
|
||||
assert _mode(parent_cache_dir) == dir_mode
|
||||
assert _mode(cache_dir) == dir_mode
|
||||
|
||||
@@ -55,7 +55,7 @@ def test_subrepo_is_constructed_properly(
|
||||
|
||||
subrepo = tmp_dir / "subrepo"
|
||||
make_subrepo(subrepo, scm)
|
||||
local_cache = subrepo.dvc.odb.local.path
|
||||
local_cache = subrepo.dvc.cache.local.path
|
||||
|
||||
tmp_dir.scm_gen("bar", "bar", commit="add bar")
|
||||
subrepo.dvc_gen("foo", "foo", commit="add foo")
|
||||
@@ -72,16 +72,16 @@ def test_subrepo_is_constructed_properly(
|
||||
|
||||
assert repo.url == str(tmp_dir)
|
||||
assert repo.config["cache"]["dir"] == str(cache_dir)
|
||||
assert repo.odb.local.path == str(cache_dir)
|
||||
assert subrepo.odb.local.path == str(cache_dir)
|
||||
assert repo.cache.local.path == str(cache_dir)
|
||||
assert subrepo.cache.local.path == str(cache_dir)
|
||||
|
||||
assert repo.config["cache"]["type"] == ["symlink"]
|
||||
assert repo.odb.local.cache_types == ["symlink"]
|
||||
assert subrepo.odb.local.cache_types == ["symlink"]
|
||||
assert repo.cache.local.cache_types == ["symlink"]
|
||||
assert subrepo.cache.local.cache_types == ["symlink"]
|
||||
|
||||
assert subrepo.config["remote"]["auto-generated-upstream"]["url"] == local_cache
|
||||
if root_is_dvc:
|
||||
main_cache = tmp_dir.dvc.odb.local.path
|
||||
main_cache = tmp_dir.dvc.cache.local.path
|
||||
assert repo.config["remote"]["auto-generated-upstream"]["url"] == str(
|
||||
main_cache
|
||||
)
|
||||
|
||||
@@ -45,7 +45,7 @@ def find_supported_remotes(string):
|
||||
def test_info_in_repo(scm_init, tmp_dir):
|
||||
tmp_dir.init(scm=scm_init, dvc=True)
|
||||
# Create `.dvc/cache`, that is needed to check supported link types.
|
||||
os.mkdir(tmp_dir.dvc.odb.local.path)
|
||||
os.mkdir(tmp_dir.dvc.cache.local.path)
|
||||
|
||||
dvc_info = get_dvc_info()
|
||||
|
||||
@@ -113,7 +113,7 @@ def test_remotes(tmp_dir, dvc, caplog):
|
||||
|
||||
|
||||
def test_fs_info_in_repo(tmp_dir, dvc, caplog):
|
||||
os.mkdir(dvc.odb.local.path)
|
||||
os.mkdir(dvc.cache.local.path)
|
||||
dvc_info = get_dvc_info()
|
||||
|
||||
assert re.search(r"Cache directory: .* on .*", dvc_info)
|
||||
|
||||
Reference in New Issue
Block a user