mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
dep: repo: use dvcfs
Makes dvc get/import/etc use dvcfs, which already supports cloud versioning, circular imports and other stuff. Also makes dvc import behave more like dvc import-url, so that we can use the same existing logic for fetching those using index instead of objects. Fixes #8789 Related iterative/studio#4782
This commit is contained in:
@@ -226,12 +226,13 @@ def test_pull_git_imports(tmp_dir, dvc, scm, erepo):
|
||||
|
||||
assert dvc.pull()["fetched"] == 0
|
||||
|
||||
for item in ["foo", "new_dir", dvc.cache.local.path]:
|
||||
for item in ["foo", "new_dir"]:
|
||||
remove(item)
|
||||
dvc.cache.local.clear()
|
||||
os.makedirs(dvc.cache.local.path, exist_ok=True)
|
||||
clean_repos()
|
||||
|
||||
assert dvc.pull(force=True)["fetched"] == 3
|
||||
assert dvc.pull(force=True)["fetched"] == 2
|
||||
|
||||
assert (tmp_dir / "foo").exists()
|
||||
assert (tmp_dir / "foo").read_text() == "foo"
|
||||
|
||||
@@ -8,7 +8,6 @@ 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
|
||||
from dvc.fs import system
|
||||
from dvc.scm import Git
|
||||
from dvc.stage.exceptions import StagePathNotFoundError
|
||||
@@ -240,7 +239,9 @@ def test_pull_import_no_download(tmp_dir, scm, dvc, erepo_dir):
|
||||
dvc.imp(os.fspath(erepo_dir), "foo", "foo_imported", no_download=True)
|
||||
|
||||
dvc.pull(["foo_imported.dvc"])
|
||||
assert os.path.exists("foo_imported")
|
||||
assert (tmp_dir / "foo_imported").exists
|
||||
assert (tmp_dir / "foo_imported" / "bar").read_bytes() == b"bar"
|
||||
assert (tmp_dir / "foo_imported" / "baz").read_bytes() == b"baz contents"
|
||||
|
||||
stage = load_file(dvc, "foo_imported.dvc").stage
|
||||
|
||||
@@ -338,34 +339,7 @@ def test_push_wildcard_from_bare_git_repo(
|
||||
with dvc_repo.chdir():
|
||||
dvc_repo.dvc.imp(os.fspath(tmp_dir), "dirextra")
|
||||
|
||||
with pytest.raises(FileNotFoundError):
|
||||
dvc_repo.dvc.imp(os.fspath(tmp_dir), "dir123")
|
||||
|
||||
|
||||
def test_download_error_pulling_imported_stage(mocker, tmp_dir, dvc, erepo_dir):
|
||||
with erepo_dir.chdir():
|
||||
erepo_dir.dvc_gen("foo", "foo content", commit="create foo")
|
||||
dvc.imp(os.fspath(erepo_dir), "foo", "foo_imported")
|
||||
|
||||
dst_stage = load_file(dvc, "foo_imported.dvc").stage
|
||||
dst_cache = dst_stage.outs[0].cache_path
|
||||
|
||||
remove("foo_imported")
|
||||
remove(dst_cache)
|
||||
|
||||
def unreliable_download(_from_fs, from_info, _to_fs, to_info, **kwargs):
|
||||
on_error = kwargs["on_error"]
|
||||
assert on_error
|
||||
if isinstance(from_info, str):
|
||||
from_info = [from_info]
|
||||
if isinstance(to_info, str):
|
||||
to_info = [to_info]
|
||||
for from_i, to_i in zip(from_info, to_info):
|
||||
on_error(from_i, to_i, Exception())
|
||||
|
||||
mocker.patch("dvc_objects.fs.generic.transfer", unreliable_download)
|
||||
with pytest.raises(DownloadError):
|
||||
dvc.pull(["foo_imported.dvc"])
|
||||
dvc_repo.dvc.imp(os.fspath(tmp_dir), "dir123")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("dname", [".", "dir", "dir/subdir"])
|
||||
@@ -634,21 +608,6 @@ def test_chained_import(tmp_dir, dvc, make_tmp_dir, erepo_dir, local_cloud):
|
||||
assert (dst / "bar").read_text() == "bar"
|
||||
|
||||
|
||||
def test_circular_import(tmp_dir, dvc, scm, erepo_dir):
|
||||
from dvc.exceptions import CircularImportError
|
||||
|
||||
with erepo_dir.chdir():
|
||||
erepo_dir.dvc_gen({"dir": {"foo": "foo", "bar": "bar"}}, commit="init")
|
||||
|
||||
dvc.imp(os.fspath(erepo_dir), "dir", "dir_imported")
|
||||
scm.add("dir_imported.dvc")
|
||||
scm.commit("import")
|
||||
|
||||
with erepo_dir.chdir():
|
||||
with pytest.raises(CircularImportError):
|
||||
erepo_dir.dvc.imp(os.fspath(tmp_dir), "dir_imported", "circular_import")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("paths", ([], ["dir"]))
|
||||
def test_parameterized_repo(tmp_dir, dvc, scm, erepo_dir, paths):
|
||||
path = erepo_dir.joinpath(*paths)
|
||||
|
||||
Reference in New Issue
Block a user