failing while pulling imported directories (#2692)

* pull: fix-2684 - failing while pulling imported directories

* pull: fix-2684 - fix code indentation

* minor imported directories pull test update

Co-Authored-By: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
Ivan Shcheklein
2019-10-30 17:18:07 +02:00
committed by Ruslan Kuprieiev
co-authored by Ruslan Kuprieiev
parent 77fcd49695
commit 2ec0aa0c37
3 changed files with 32 additions and 14 deletions
+1 -1
View File
@@ -334,7 +334,7 @@ class OutputBase(object):
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.
+13 -13
View File
@@ -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:
+18
View File
@@ -2,6 +2,7 @@ from __future__ import unicode_literals
import os
import filecmp
import shutil
import pytest
from mock import patch
@@ -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"