Example #1
0
def _checkout(
    diff,
    fs_path,
    fs,
    cache,
    force=False,
    progress_callback=None,
    relink=False,
    state=None,
):
    if not diff:
        return

    links = test_links(cache.cache_types, cache.fs, cache.fs_path, fs, fs_path)
    if not links:
        raise CacheLinkError([fs_path])
    link = Link(links)

    for change in diff.deleted:
        entry_path = (
            fs.path.join(fs_path, *change.old.key)
            if change.old.key != ROOT
            else fs_path
        )
        _remove(entry_path, fs, change.old.in_cache, force=force)

    failed = []
    for change in chain(diff.added, diff.modified):
        entry_path = (
            fs.path.join(fs_path, *change.new.key)
            if change.new.key != ROOT
            else fs_path
        )
        if change.new.oid.isdir:
            fs.makedirs(entry_path)
            continue

        try:
            _checkout_file(
                link,
                entry_path,
                fs,
                change,
                cache,
                force,
                progress_callback,
                relink,
                state=state,
            )
        except CheckoutError as exc:
            failed.extend(exc.target_infos)

    if failed:
        raise CheckoutError(failed)
Example #2
0
    def __call__(self, cache, from_path, to_fs, to_path):
        if to_fs.exists(to_path):
            to_fs.remove(to_path)  # broken symlink

        cache.makedirs(cache.fs.path.parent(to_path))
        try:
            transfer(cache.fs, from_path, to_fs, to_path, links=self._links)
        except FileNotFoundError as exc:
            raise CheckoutError([to_path]) from exc
        except OSError as exc:
            raise CacheLinkError([to_path]) from exc
Example #3
0
 def commit(self, allow_missing=False):
     link_failures = []
     for out in self.outs:
         try:
             out.commit()
         except OutputDoesNotExistError:
             if not (allow_missing or out.checkpoint):
                 raise
         except CacheLinkError:
             link_failures.append(out.path_info)
     if link_failures:
         raise CacheLinkError(link_failures)
Example #4
0
    def _checkout(self, *args, **kwargs):
        from dvc_data.checkout import CheckoutError as _CheckoutError
        from dvc_data.checkout import LinkError, PromptError

        try:
            return checkout(*args, **kwargs)
        except PromptError as exc:
            raise ConfirmRemoveError(exc.path)
        except LinkError as exc:
            raise CacheLinkError([exc.path])
        except _CheckoutError as exc:
            raise CheckoutError(exc.paths)
Example #5
0
def _try_links(cache, from_info, to_info, link_types):
    while link_types:
        link_method = getattr(cache.fs, link_types[0])
        try:
            _do_link(cache, from_info, to_info, link_method)
            _verify_link(cache, to_info, link_types[0])
            return

        except DvcException as exc:
            logger.debug("Cache type '%s' is not supported: %s", link_types[0],
                         exc)
            del link_types[0]

    raise CacheLinkError([to_info])
Example #6
0
    def commit(self, allow_missing=False, filter_info=None):
        from dvc.output.base import OutputDoesNotExistError

        link_failures = []
        for out in self.filter_outs(filter_info):
            try:
                out.commit(filter_info=filter_info)
            except OutputDoesNotExistError:
                if not (allow_missing or out.checkpoint):
                    raise
            except CacheLinkError:
                link_failures.append(out.path_info)
        if link_failures:
            raise CacheLinkError(link_failures)
Example #7
0
File: checkout.py Project: Suor/dvc
def _try_links(cache, from_info, to_info, link_types):
    while link_types:
        link_method = getattr(cache.fs, link_types[0])
        try:
            _do_link(cache, from_info, to_info, link_method)
            _verify_link(cache, to_info, link_types[0])
            return

        except OSError as exc:
            if exc.errno not in [errno.EXDEV, errno.ENOTSUP]:
                raise
            logger.debug("Cache type '%s' is not supported: %s", link_types[0],
                         exc)
            del link_types[0]

    raise CacheLinkError([to_info])