Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions dvc/dependency/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ def _make_repo(self, **overrides):

def status(self):
with self._make_repo() as repo:
current = repo.find_out_by_relpath(self.def_path).info
current = repo.find_out_by_path(self.def_path).info

with self._make_repo(rev_lock=None) as repo:
updated = repo.find_out_by_relpath(self.def_path).info
updated = repo.find_out_by_path(self.def_path).info

if current != updated:
return {str(self): "update available"}
Expand All @@ -71,7 +71,7 @@ def fetch(self):
) as repo:
self.def_repo[self.PARAM_REV_LOCK] = repo.scm.get_rev()

out = repo.find_out_by_relpath(self.def_path)
out = repo.find_out_by_path(self.def_path)
with repo.state:
repo.cloud.pull(out.get_used_cache())

Expand Down
12 changes: 11 additions & 1 deletion dvc/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ class OutputNotFoundError(DvcException):
"""

def __init__(self, output):
self.failed_output = output
super(OutputNotFoundError, self).__init__(
"unable to find DVC-file with output '{path}'".format(
path=relpath(output)
path=relpath(self.failed_output)
)
)

Expand Down Expand Up @@ -328,3 +329,12 @@ def __init__(self, target_infos):

class CollectCacheError(DvcException):
pass


class NoOutputInExternalRepoError(DvcException):
def __init__(self, repo_url, path):
super(NoOutputInExternalRepoError, self).__init__(
"Output: '{}' not found in target repository: '{}'".format(
path, repo_url
)
)
7 changes: 6 additions & 1 deletion dvc/external_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

from funcy import retry

from dvc.exceptions import NoOutputInExternalRepoError
from dvc.exceptions import OutputNotFoundError
from dvc.utils import remove


Expand All @@ -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 OutputNotFoundError as e:
raise NoOutputInExternalRepoError(url, e.failed_output)
repo.close()


Expand Down
12 changes: 8 additions & 4 deletions dvc/repo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,15 @@ def stages(self):
return get_stages(self.graph)

def find_outs_by_path(self, path, outs=None, recursive=False):
abs_path = (
os.path.join(self.root_dir, path)
if not os.path.isabs(path)
else path
)

if not outs:
outs = [out for stage in self.stages for out in stage.outs]

abs_path = os.path.abspath(path)
is_dir = self.tree.isdir(abs_path)

def func(out):
Expand All @@ -439,9 +444,8 @@ def func(out):

return matched

def find_out_by_relpath(self, relpath):
path = os.path.join(self.root_dir, relpath)
out, = self.find_outs_by_path(path)
def find_out_by_path(self, relpath):
out, = self.find_outs_by_path(relpath)
return out

def is_dvc_internal(self, path):
Expand Down
2 changes: 1 addition & 1 deletion dvc/repo/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def _fetch_external(self, repo_url, repo_rev, files):
cache = NamedCache()
for name in files:
try:
out = repo.find_out_by_relpath(name)
out = repo.find_out_by_path(name)
except OutputNotFoundError:
failed += 1
logger.exception(
Expand Down
2 changes: 1 addition & 1 deletion dvc/repo/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def get(url, path, out=None, rev=None):
# the same cache file might be used a few times in a directory.
repo.cache.local.cache_types = ["reflink", "hardlink", "copy"]

o = repo.find_out_by_relpath(path)
o = repo.find_out_by_path(path)
with repo.state:
repo.cloud.pull(o.get_used_cache())
o.path_info = PathInfo(os.path.abspath(out))
Expand Down