From b44e1c3646a9833e9ed36aa379c4517d3aced03e Mon Sep 17 00:00:00 2001 From: Batuhan Taskaya Date: Tue, 17 Aug 2021 02:51:08 +0300 Subject: [PATCH] fetched: correctly order mixed odbs (#6436) --- dvc/repo/fetch.py | 3 ++- tests/func/test_data_cloud.py | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/dvc/repo/fetch.py b/dvc/repo/fetch.py index d9cee65aa..c7af1179b 100644 --- a/dvc/repo/fetch.py +++ b/dvc/repo/fetch.py @@ -61,7 +61,8 @@ def fetch( for odb, obj_ids in sorted( used.items(), - key=lambda item: item[0] and item[0].fs.scheme == Schemes.MEMORY, + key=lambda item: item[0] is not None + and item[0].fs.scheme == Schemes.MEMORY, ): d, f = _fetch( self, diff --git a/tests/func/test_data_cloud.py b/tests/func/test_data_cloud.py index 2fb4cd42c..fb51701ff 100644 --- a/tests/func/test_data_cloud.py +++ b/tests/func/test_data_cloud.py @@ -350,6 +350,27 @@ def test_pull_external_dvc_imports(tmp_dir, dvc, scm, erepo_dir): assert (tmp_dir / "new_dir" / "bar").read_text() == "bar" +def test_pull_external_dvc_imports_mixed( + tmp_dir, dvc, scm, erepo_dir, local_remote +): + with erepo_dir.chdir(): + erepo_dir.dvc_gen("foo", "foo", commit="first") + os.remove("foo") + + # imported: foo + dvc.imp(os.fspath(erepo_dir), "foo") + + # local-object: bar + tmp_dir.dvc_gen("bar", "bar") + dvc.push("bar") + + clean(["foo", "bar"], dvc) + + assert dvc.pull()["fetched"] == 2 + assert (tmp_dir / "foo").read_text() == "foo" + assert (tmp_dir / "bar").read_text() == "bar" + + def clean(outs, dvc=None): from tests.utils import clean_staging