Skip to content
/ dvc Public
forked from iterative/dvc

Commit

Permalink
fix partial fetch
Browse files Browse the repository at this point in the history
Closes iterative#10199. Bumps dvc-data to >=3.4.
  • Loading branch information
skshetry committed Dec 27, 2023
1 parent 402c107 commit 10946c9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 20 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ dependencies = [
"configobj>=5.0.6",
"distro>=1.3",
"dpath<3,>=2.1.0",
"dvc-data>=3.3,<3.4",
"dvc-data>=3.4,<3.5",
"dvc-http>=2.29.0",
"dvc-render>=1.0.0,<2",
"dvc-studio-client>=0.17.1,<1",
Expand Down
5 changes: 3 additions & 2 deletions tests/func/test_data_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,12 +481,13 @@ def test_push_pull_fetch_pipeline_stages(tmp_dir, dvc, run_copy, local_remote):


def test_pull_partial(tmp_dir, dvc, local_remote):
tmp_dir.dvc_gen({"foo": {"bar": {"baz": "baz"}, "spam": "spam"}})
other_files = {f"spam{i}": f"spam{i}" for i in range(10)}
tmp_dir.dvc_gen({"foo": {"bar": {"baz": "baz"}, **other_files}})
dvc.push()
clean(["foo"], dvc)

stats = dvc.pull(os.path.join("foo", "bar"))
assert stats["fetched"] == 3
assert stats["fetched"] == 2
assert (tmp_dir / "foo").read_text() == {"bar": {"baz": "baz"}}


Expand Down
29 changes: 12 additions & 17 deletions tests/func/test_virtual_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,32 +166,27 @@ def test_virtual_update_noop(tmp_dir, dvc, remote):


def test_partial_checkout_and_update(M, tmp_dir, dvc, remote):
tmp_dir.gen({"dir": {"foo": "foo", "subdir": {"lorem": "lorem"}}})
dir1 = {f"{i}.txt": f"dir1 {i}" for i in range(10)}
dir2 = {f"{i}.txt": f"dir2 {i}" for i in range(10)}
tmp_dir.gen({"dir": {"foo": "foo", "subdir": dir1, "subdir2": dir2}})

(stage,) = dvc.add("dir")
out = stage.outs[0]

assert out.hash_info == HashInfo(
name="md5", value="22a16c9bf84b3068bc2206d88a6b5776.dir"
)
assert out.meta == Meta(isdir=True, size=8, nfiles=2)
assert out.hash_info == HashInfo("md5", "9899dc38082ee0ec33de077df62a4a12.dir")
assert out.meta == Meta(isdir=True, size=123, nfiles=21)

assert dvc.push() == 3
assert dvc.push() == 22
dvc.cache.local.clear()
shutil.rmtree("dir")

assert dvc.pull("dir/subdir") == M.dict(
added=[join("dir", "")],
fetched=3,
)
assert (tmp_dir / "dir").read_text() == {"subdir": {"lorem": "lorem"}}
assert dvc.pull("dir/subdir") == M.dict(added=[join("dir", "")], fetched=11)
assert (tmp_dir / "dir").read_text() == {"subdir": dir1}

tmp_dir.gen({"dir": {"subdir": {"ipsum": "ipsum"}}})
(stage,) = dvc.add("dir/subdir/ipsum")
tmp_dir.gen({"dir": {"subdir": {"file": "file"}}})
(stage,) = dvc.add(join("dir", "subdir", "file"))

out = stage.outs[0]
assert out.hash_info == HashInfo(
name="md5", value="06d953a10e0b0ffacba04876a9351e39.dir"
)
assert out.meta == Meta(isdir=True, size=13, nfiles=3)
assert out.hash_info == HashInfo("md5", "e7531c3930f28a00edc25e6cef91db03.dir")
assert out.meta == Meta(isdir=True, size=127, nfiles=22)
assert dvc.push() == 2

0 comments on commit 10946c9

Please sign in to comment.