From b221c16c898f6e18f995aeefbc08e57c2511253e Mon Sep 17 00:00:00 2001 From: Batuhan Taskaya Date: Tue, 9 Mar 2021 16:36:44 +0300 Subject: [PATCH] pull: proper path join for partial pulls (#5579) * pull: proper path join for partial pulls * use os.path.join in the tests for windows --- dvc/output/base.py | 2 +- tests/func/test_data_cloud.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/dvc/output/base.py b/dvc/output/base.py index be250f112..30565d218 100644 --- a/dvc/output/base.py +++ b/dvc/output/base.py @@ -475,7 +475,7 @@ class BaseOutput: return 0 return ilen( - filter_info.isin_or_eq(self.path_info / relpath) + filter_info.isin_or_eq(self.path_info.joinpath(*relpath)) for relpath, _ in self.hash_info.dir_info.items() ) diff --git a/tests/func/test_data_cloud.py b/tests/func/test_data_cloud.py index 92021c8ce..a0ab15032 100644 --- a/tests/func/test_data_cloud.py +++ b/tests/func/test_data_cloud.py @@ -537,3 +537,13 @@ def test_push_pull_fetch_pipeline_stages(tmp_dir, dvc, run_copy, local_remote): dvc.fetch("copy-foo-bar") assert len(recurse_list_dir(dvc.odb.local.cache_dir)) == 1 + + +def test_pull_partial(tmp_dir, dvc, local_remote): + tmp_dir.dvc_gen({"foo": {"bar": {"baz": "baz"}, "spam": "spam"}}) + dvc.push() + clean(["foo"], dvc) + + stats = dvc.pull(os.path.join("foo", "bar")) + assert stats["fetched"] == 1 + assert (tmp_dir / "foo").read_text() == {"bar": {"baz": "baz"}}