mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
repo: move state/index/data_index to site_cache_dir
We use all of these for optimization and should not depend on a potentially slow or broken
filesystem on which repository resides (could be HDD or CIFS/NFS/overlayfs/etc).
This PR means a few things:
* all odd filesystems that dvc repo might be on will work quickly out of the box
* when we start caching cloned repositories for `dvc get/import`, we will be
able to cache indexes for them as well (note that bare clones don't have a
worktree so there is no place for .dvc/tmp with the old approach).
* `index.dir` and `state.dir` are now obsolete.
* `dvc init` will cleanup site_cache_dir.
Related #5562
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
import os
|
||||
import re
|
||||
|
||||
from dvc.repo import Repo
|
||||
from dvc_data.hashfile.hash import file_md5
|
||||
from dvc_data.hashfile.hash_info import HashInfo
|
||||
from dvc_data.hashfile.state import State
|
||||
@@ -71,15 +69,3 @@ def test_get_unused_links(tmp_dir, dvc):
|
||||
dvc.fs,
|
||||
)
|
||||
) == {"bar"}
|
||||
|
||||
|
||||
def test_state_dir_config(make_tmp_dir, dvc):
|
||||
assert dvc.state.tmp_dir == dvc.tmp_dir
|
||||
|
||||
index_dir = str(make_tmp_dir("tmp_index"))
|
||||
repo = Repo(config={"state": {"dir": index_dir}})
|
||||
assert os.path.dirname(repo.state.tmp_dir) == os.path.join(index_dir, ".dvc")
|
||||
assert re.match(
|
||||
r"^test_state_dir_config0-([0-9a-f]+)$",
|
||||
os.path.basename(repo.state.tmp_dir),
|
||||
)
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
import os
|
||||
|
||||
import pytest
|
||||
from dvc_gs import GSFileSystem
|
||||
from dvc_s3 import S3FileSystem
|
||||
|
||||
from dvc.fs import get_cloud_fs
|
||||
from dvc_data.hashfile.db import get_index
|
||||
|
||||
|
||||
def test_remote_with_hash_jobs(dvc):
|
||||
@@ -57,18 +54,3 @@ def test_makedirs_not_create_for_top_level_path(fs_cls, dvc, mocker):
|
||||
|
||||
fs.makedirs(url)
|
||||
assert not mocked_client.called
|
||||
|
||||
|
||||
def test_remote_index_dir_config(make_tmp_dir, dvc):
|
||||
index_dir = str(make_tmp_dir("tmp_index"))
|
||||
with dvc.config.edit() as conf:
|
||||
conf["index"]["dir"] = index_dir
|
||||
conf["remote"]["s3"] = {"url": "s3://bucket/name"}
|
||||
|
||||
dvc.root_dir = "/usr/local/test_repo"
|
||||
dvc.dvc_dir = "/usr/local/test_repo/.dvc"
|
||||
dvc.__dict__.pop("local_dvc_dir")
|
||||
|
||||
assert os.path.dirname(
|
||||
get_index(dvc.cloud.get_remote_odb(name="s3")).index_dir
|
||||
) == os.path.join(index_dir, ".dvc", "test_repo-a473718", "index")
|
||||
|
||||
Reference in New Issue
Block a user