From 42ce19b88aa6654a82ee2d1a9b7faa8f1849aaa1 Mon Sep 17 00:00:00 2001 From: Alexander Schepanovski Date: Mon, 14 Oct 2019 16:06:58 +0700 Subject: [PATCH 1/2] dvc: wrap checkout error as download error in Repo.fetch() This will happen on missing caches and similar to download error in its effect. --- dvc/repo/fetch.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dvc/repo/fetch.py b/dvc/repo/fetch.py index 3f0bce1eb9..140b3270be 100644 --- a/dvc/repo/fetch.py +++ b/dvc/repo/fetch.py @@ -3,7 +3,7 @@ import logging from dvc.config import NoRemoteError -from dvc.exceptions import DownloadError, OutputNotFoundError +from dvc.exceptions import DownloadError, OutputNotFoundError, CheckoutError from dvc.scm.base import CloneError @@ -64,7 +64,7 @@ def _fetch( downloaded += out.get_files_number() except DownloadError as exc: failed += exc.amount - except (CloneError, OutputNotFoundError): + except (CloneError, OutputNotFoundError, CheckoutError): failed += 1 logger.exception( "failed to fetch data for '{}'".format(dep.stage.outs[0]) From 759f8b9807c1e89ef73387014bcc173668a8cb8e Mon Sep 17 00:00:00 2001 From: Alexander Schepanovski Date: Tue, 22 Oct 2019 14:23:44 +0700 Subject: [PATCH 2/2] dvc: show CheckoutError/DownloadError discrepancy --- dvc/repo/fetch.py | 4 ++-- dvc/repo/pull.py | 1 + tests/func/test_import.py | 7 +++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/dvc/repo/fetch.py b/dvc/repo/fetch.py index 140b3270be..3f0bce1eb9 100644 --- a/dvc/repo/fetch.py +++ b/dvc/repo/fetch.py @@ -3,7 +3,7 @@ import logging from dvc.config import NoRemoteError -from dvc.exceptions import DownloadError, OutputNotFoundError, CheckoutError +from dvc.exceptions import DownloadError, OutputNotFoundError from dvc.scm.base import CloneError @@ -64,7 +64,7 @@ def _fetch( downloaded += out.get_files_number() except DownloadError as exc: failed += exc.amount - except (CloneError, OutputNotFoundError, CheckoutError): + except (CloneError, OutputNotFoundError): failed += 1 logger.exception( "failed to fetch data for '{}'".format(dep.stage.outs[0]) diff --git a/dvc/repo/pull.py b/dvc/repo/pull.py index 7c92588247..d455fe4a34 100644 --- a/dvc/repo/pull.py +++ b/dvc/repo/pull.py @@ -24,6 +24,7 @@ def pull( with_deps=with_deps, recursive=recursive, ) + # This throws CheckoutError self._checkout( targets=targets, with_deps=with_deps, force=force, recursive=recursive ) diff --git a/tests/func/test_import.py b/tests/func/test_import.py index 0d1f17e996..3994a38e4c 100644 --- a/tests/func/test_import.py +++ b/tests/func/test_import.py @@ -2,6 +2,7 @@ import os import filecmp +import shutil import pytest from mock import patch @@ -84,6 +85,12 @@ def test_download_error_pulling_imported_stage(dvc_repo, erepo): ), pytest.raises(DownloadError): dvc_repo.pull(["foo_imported.dvc"]) + # When repo is absent we should still get DownloadError + shutil.rmtree(erepo.dvc.cache.local.cache_dir) + + with pytest.raises(DownloadError): + dvc_repo.pull(["foo_imported.dvc"]) + @pytest.mark.parametrize("dname", [".", "dir", "dir/subdir"]) def test_import_to_dir(dname, repo_dir, dvc_repo, erepo):