Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failing while pulling imported directories #2692

Merged
merged 3 commits into from
Oct 30, 2019
Merged
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
2 changes: 1 addition & 1 deletion dvc/output/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def unprotect(self):
self.remote.unprotect(self.path_info)

def _collect_used_dir_cache(self, remote=None, force=False, jobs=None):
"""Get a list of `info`s retaled to the given directory.
"""Get a list of `info`s related to the given directory.

- Pull the directory entry from the remote cache if it was changed.

Expand Down
26 changes: 13 additions & 13 deletions dvc/repo/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,20 @@ def _fetch_external(self, repo_url, repo_rev, files):
cache_dir = self.cache.local.cache_dir
try:
with external_repo(repo_url, repo_rev, cache_dir=cache_dir) as repo:
cache = NamedCache()
for name in files:
try:
out = repo.find_out_by_relpath(name)
except OutputNotFoundError:
failed += 1
logger.exception(
"failed to fetch data for '{}'".format(name)
)
continue
else:
cache.update(out.get_used_cache())

with repo.state:
cache = NamedCache()
for name in files:
try:
out = repo.find_out_by_relpath(name)
except OutputNotFoundError:
failed += 1
logger.exception(
"failed to fetch data for '{}'".format(name)
)
continue
else:
cache.update(out.get_used_cache())

try:
return repo.cloud.pull(cache), failed
except DownloadError as exc:
Expand Down
18 changes: 18 additions & 0 deletions tests/func/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import os
import filecmp
import shutil

import pytest
from mock import patch
Expand Down Expand Up @@ -67,6 +68,23 @@ def test_pull_imported_stage(dvc_repo, erepo):
assert os.path.isfile(dst_cache)


def test_pull_imported_directory_stage(dvc_repo, erepo):
src = erepo.DATA_DIR
dst = erepo.DATA_DIR + "_imported"
stage_file = dst + ".dvc"

dvc_repo.imp(erepo.root_dir, src, dst)

shutil.rmtree(dst)
shutil.rmtree(dvc_repo.cache.local.cache_dir)

dvc_repo.pull([stage_file])

assert os.path.exists(dst)
assert os.path.isdir(dst)
trees_equal(src, dst)


def test_download_error_pulling_imported_stage(dvc_repo, erepo):
src = erepo.FOO
dst = erepo.FOO + "_imported"
Expand Down