Skip to content

dvc commit fails with files imported via dvc import #4205

@alessio-ca

Description

@alessio-ca

Bug Report

Hello! I am importing some files in my main repo from another repo using the command dvc import.
Upon running dvc commit afterward, I get the following error (output of dvc commit -v):

2020-07-14 18:50:54,511 ERROR: unexpected error - 'NoneType' object has no attribute 'scheme'
------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/Cellar/dvc/1.1.10/libexec/lib/python3.8/site-packages/dvc/main.py", line 53, in main
    ret = cmd.run()
  File "/usr/local/Cellar/dvc/1.1.10/libexec/lib/python3.8/site-packages/dvc/command/commit.py", line 18, in run
    self.repo.commit(
  File "/usr/local/Cellar/dvc/1.1.10/libexec/lib/python3.8/site-packages/dvc/repo/__init__.py", line 36, in wrapper
    ret = f(repo, *args, **kwargs)
  File "/usr/local/Cellar/dvc/1.1.10/libexec/lib/python3.8/site-packages/dvc/repo/commit.py", line 42, in commit
    changes = stage.changed_entries()
  File "/usr/local/Cellar/dvc/1.1.10/libexec/lib/python3.8/site-packages/dvc/stage/__init__.py", line 405, in changed_entries
    changed_deps = self._changed_entries(self.deps)
  File "/usr/local/Cellar/dvc/1.1.10/libexec/lib/python3.8/site-packages/dvc/stage/__init__.py", line 399, in _changed_entries
    return [str(entry) for entry in entries if entry.changed_checksum()]
  File "/usr/local/Cellar/dvc/1.1.10/libexec/lib/python3.8/site-packages/dvc/stage/__init__.py", line 399, in <listcomp>
    return [str(entry) for entry in entries if entry.changed_checksum()]
  File "/usr/local/Cellar/dvc/1.1.10/libexec/lib/python3.8/site-packages/dvc/output/base.py", line 195, in changed_checksum
    return self.checksum != self.get_checksum()
  File "/usr/local/Cellar/dvc/1.1.10/libexec/lib/python3.8/site-packages/dvc/output/base.py", line 181, in get_checksum
    return self.remote.get_hash(self.path_info)
  File "/usr/local/Cellar/dvc/1.1.10/libexec/lib/python3.8/site-packages/dvc/remote/base.py", line 735, in get_hash
    return self.tree.get_hash(path_info, **kwargs)
  File "/usr/local/Cellar/dvc/1.1.10/libexec/lib/python3.8/site-packages/dvc/remote/base.py", line 276, in get_hash
    assert isinstance(path_info, str) or path_info.scheme == self.scheme
AttributeError: 'NoneType' object has no attribute 'scheme'
------------------------------------------------------------

If I perform dvc add on the files imported (effectively "pinning" them to the main repo) the error disappears and the command executes successfully.

As a workaround, adding the following lines before the assert statement in the function get_hash() in dvc/remote/base.py gets rid of the error even for files imported via dvc import:

    def get_hash(self, path_info, tree=None, **kwargs):
        if not path_info:
            return None

        assert isinstance(path_info, str) or path_info.scheme == self.scheme

I never had any problem with DVC<1.0.0
My setup:

DVC version: 1.1.10
Python version: 3.8.3
Platform: macOS-10.14.6-x86_64-i386-64bit
Binary: False
Package: brew
Supported remotes: azure, gdrive, gs, http, https, s3, ssh, oss
Cache: reflink - supported, hardlink - supported, symlink - supported
Repo: dvc, git

Metadata

Metadata

Assignees

Labels

bugDid we break something?

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions