Skip to content

api: does not work with git only local repository #3221

@skshetry

Description

@skshetry
cd "$(mktemp -d)" 
➜ git init
Initialized empty Git repository in /tmp/tmp.TGV6SVXYsz/.git/

➜ echo "foo" > foo
➜ git add foo
➜ git -c commit.gpgsign=false commit -m "first"
[master (root-commit) 136fd94] first
 1 file changed, 1 insertion(+)
 create mode 100644 foo

➜ python -c '
➜ import dvc.api
➜ with dvc.api.open(path="foo", repo=".") as fd:
➜     print(fd.read())
'
Traceback (most recent call last):
  File "<string>", line 3, in <module>
  File "/home/saugat/.pyenv/versions/3.6.6/lib/python3.6/contextlib.py", line 81, in __enter__
    return next(self.gen)
  File "/home/saugat/repos/iterative/dvc/dvc/api.py", line 95, in _open
    with _make_repo(repo, rev=rev) as _repo:
  File "/home/saugat/.pyenv/versions/3.6.6/lib/python3.6/contextlib.py", line 81, in __enter__
    return next(self.gen)
  File "/home/saugat/repos/iterative/dvc/dvc/api.py", line 113, in _make_repo
    yield Repo(repo_url)
  File "/home/saugat/repos/iterative/dvc/dvc/repo/__init__.py", line 76, in __init__
    root_dir = self.find_root(root_dir)
  File "/home/saugat/repos/iterative/dvc/dvc/repo/__init__.py", line 144, in find_root
    raise NotDvcRepoError(root)
dvc.exceptions.NotDvcRepoError: you are not inside of a dvc repository (checked up to mount point '/tmp')

This is because of the recent changes in _make_repo that instead of falling back to external repo on error, it assumes the local path to be a DVC repository.
https://github.com/iterative/dvc/blob/e9caa44b554daf7f0f21dc2bb9bb0df028369fb1/dvc/api.py#L112-L113

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugDid we break something?p1-importantImportant, aka current backlog of things to do

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions