diff --git a/dvc/exceptions.py b/dvc/exceptions.py index 291606614..3c85f3dae 100644 --- a/dvc/exceptions.py +++ b/dvc/exceptions.py @@ -338,3 +338,12 @@ class RemoteNotSpecifiedInExternalRepoError(DvcException): ), cause=cause, ) + + +class NoOutputInExternalRepoError(DvcException): + def __init__(self, repo_url, path): + super(NoOutputInExternalRepoError, self).__init__( + "Output '{}' not found in target repository: '{}'".format( + path, repo_url + ) + ) diff --git a/dvc/repo/imp.py b/dvc/repo/imp.py index 68ead389b..869039266 100644 --- a/dvc/repo/imp.py +++ b/dvc/repo/imp.py @@ -1,6 +1,13 @@ +from dvc.exceptions import NoOutputInExternalRepoError +from dvc.exceptions import OutputNotFoundError + + def imp(self, url, path, out=None, rev=None): erepo = {"url": url} if rev is not None: erepo["rev"] = rev - return self.imp_url(path, out=out, erepo=erepo, locked=True) + try: + return self.imp_url(path, out=out, erepo=erepo, locked=True) + except OutputNotFoundError: + raise NoOutputInExternalRepoError(url, path)