diff --git a/dvc/exceptions.py b/dvc/exceptions.py index 07a0ce8061..45322bbe57 100644 --- a/dvc/exceptions.py +++ b/dvc/exceptions.py @@ -328,3 +328,12 @@ def __init__(self, target_infos): class CollectCacheError(DvcException): pass + + +class RemoteNotSpecifiedInExternalRepoError(DvcException): + def __init__(self, url): + super(RemoteNotSpecifiedInExternalRepoError, self).__init__( + "No DVC remote is specified in the target repository '{}'".format( + url + ) + ) diff --git a/dvc/external_repo.py b/dvc/external_repo.py index ccdadf6e6b..6fab519dff 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: + raise RemoteNotSpecifiedInExternalRepoError(url) repo.close()