diff --git a/dvc/exceptions.py b/dvc/exceptions.py index 07a0ce8061..2916066146 100644 --- a/dvc/exceptions.py +++ b/dvc/exceptions.py @@ -328,3 +328,13 @@ def __init__(self, target_infos): class CollectCacheError(DvcException): pass + + +class RemoteNotSpecifiedInExternalRepoError(DvcException): + def __init__(self, url, cause=None): + super(RemoteNotSpecifiedInExternalRepoError, self).__init__( + "No DVC remote is specified in the target repository '{}'".format( + url + ), + cause=cause, + ) diff --git a/dvc/external_repo.py b/dvc/external_repo.py index ccdadf6e6b..874240bc7f 100644 --- a/dvc/external_repo.py +++ b/dvc/external_repo.py @@ -7,6 +7,8 @@ from funcy import retry +from dvc.config import NoRemoteError +from dvc.exceptions import RemoteNotSpecifiedInExternalRepoError from dvc.utils import remove @@ -19,7 +21,10 @@ def external_repo(url=None, rev=None, rev_lock=None, cache_dir=None): path = _external_repo(url=url, rev=rev_lock or rev, cache_dir=cache_dir) repo = Repo(path) - yield repo + try: + yield repo + except NoRemoteError as exc: + raise RemoteNotSpecifiedInExternalRepoError(url, cause=exc) repo.close()