fetch: use index fetch

This commit is contained in:
Ruslan Kuprieiev
2023-06-10 21:18:57 +03:00
parent 1cb371d4d7
commit 4c0bb8d316
10 changed files with 60 additions and 183 deletions
+6 -6
View File
@@ -159,8 +159,8 @@ def test_missing_cache(tmp_dir, dvc, local_remote, caplog):
"Some of the cache files do not exist "
"neither locally nor on remote. Missing cache files:\n"
)
foo = "name: bar, md5: 37b51d194a7513e45b56f6524f2d51f2\n"
bar = "name: foo, md5: acbd18db4cc2f85cedef654fccc4a4d8\n"
foo = "md5: 37b51d194a7513e45b56f6524f2d51f2\n"
bar = "md5: acbd18db4cc2f85cedef654fccc4a4d8\n"
caplog.clear()
dvc.push()
@@ -198,7 +198,7 @@ def test_verify_hashes(tmp_dir, scm, dvc, mocker, tmp_path_factory, local_remote
dvc.pull()
# NOTE: 1 is for index.data_tree building
assert hash_spy.call_count == 1
assert hash_spy.call_count == 2
# Removing cache will invalidate existing state entries
dvc.cache.local.clear()
@@ -206,7 +206,7 @@ def test_verify_hashes(tmp_dir, scm, dvc, mocker, tmp_path_factory, local_remote
dvc.config["remote"]["upstream"]["verify"] = True
dvc.pull()
assert hash_spy.call_count == 6
assert hash_spy.call_count == 8
@flaky(max_runs=3, min_passes=1)
@@ -268,7 +268,7 @@ def test_pull_partial_import(tmp_dir, dvc, local_workspace):
stage = dvc.imp_url("remote://workspace/file", os.fspath(dst), no_download=True)
result = dvc.pull("file")
assert result["fetched"] == 1
assert result["fetched"] == 0
assert dst.exists()
assert stage.outs[0].get_hash().value == "d10b4c3ff123b26dc068d43a8bef2d23"
@@ -483,7 +483,7 @@ def test_pull_partial(tmp_dir, dvc, local_remote):
clean(["foo"], dvc)
stats = dvc.pull(os.path.join("foo", "bar"))
assert stats["fetched"] == 1
assert stats["fetched"] == 3
assert (tmp_dir / "foo").read_text() == {"bar": {"baz": "baz"}}
+3 -2
View File
@@ -241,12 +241,13 @@ 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 (tmp_dir / "foo_imported").exists
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
dvc.commit(force=True)
stage = load_file(dvc, "foo_imported.dvc").stage
if os.name == "nt":
expected_hash = "2e798234df5f782340ac3ce046f8dfae.dir"
else:
+2 -1
View File
@@ -232,8 +232,9 @@ def test_partial_import_pull(tmp_dir, scm, dvc, local_workspace):
assert dst.exists()
stage = load_file(dvc, "file.dvc").stage
dvc.commit(force=True)
stage = load_file(dvc, "file.dvc").stage
assert stage.outs[0].hash_info.value == "d10b4c3ff123b26dc068d43a8bef2d23"
assert stage.outs[0].meta.size == 12
+1 -1
View File
@@ -182,7 +182,7 @@ def test_partial_checkout_and_update(M, tmp_dir, dvc, remote):
assert dvc.pull("dir/subdir") == M.dict(
added=[join("dir", "")],
fetched=1,
fetched=3,
)
assert (tmp_dir / "dir").read_text() == {"subdir": {"lorem": "lorem"}}