Skip to content
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
4 changes: 2 additions & 2 deletions dvc/output/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ def _parse_path(self, remote, path):
# FIXME: if we have Windows path containing / or posix one with \
# then we have #2059 bug and can't really handle that.
p = self.TREE_CLS.PATH_CLS(path)
if not p.is_absolute():
if self.stage and not p.is_absolute():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably remove the dependency on stage, this is very much circular: stage needs outs/deps, and outs/deps require stages, so, when we construct a stage, there's no way beforehand to create outs/deps without creating a stage first without any deps/outs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@skshetry you mean from the outputs/deps themselves? We still use it in some places, so easier said than done. Logically outs and deps do belong to the stage, but the way we create and fill them is not very friendly, I agree.

Copy link
Collaborator

@skshetry skshetry Jun 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I am trying to say is, Output should not get access to the Stage at all. We could pass wdir and repo if they need it.

p = self.stage.wdir / p

abs_p = os.path.abspath(os.path.normpath(p))
return self.TREE_CLS.PATH_CLS(abs_p)

def __str__(self):
if not self.is_in_repo:
if not self.repo or not self.is_in_repo:
return str(self.def_path)

cur_dir = os.getcwd()
Expand Down
4 changes: 3 additions & 1 deletion dvc/remote/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ def __init__(self, repo, config):

@property
def state(self):
return self.repo.state
from dvc.state import StateNoop

return self.repo.state if self.repo else StateNoop()

@cached_property
def work_tree(self):
Expand Down
2 changes: 2 additions & 0 deletions dvc/repo/get_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ def get_url(url, out=None):

(dep,) = dependency.loads_from(None, [url])
(out,) = output.loads_from(None, [out], use_cache=False)
dep.save()
dep.download(out)
out.save()
1 change: 1 addition & 0 deletions dvc/stage/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ def sync_import(stage, dry=False, force=False):
if not force and stage.already_cached():
stage.outs[0].checkout()
else:
stage.save_deps()
stage.deps[0].download(stage.outs[0])
6 changes: 6 additions & 0 deletions tests/func/test_get_url.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest

from dvc.dependency.base import DependencyDoesNotExistError
from dvc.repo import Repo


Expand All @@ -20,3 +21,8 @@ def test_get_url_to_dir(tmp_dir, dname):

assert (tmp_dir / dname).is_dir()
assert (tmp_dir / dname / "foo").read_text() == "foo contents"


def test_get_url_nonexistent(tmp_dir):
with pytest.raises(DependencyDoesNotExistError):
Repo.get_url("nonexistent")
6 changes: 6 additions & 0 deletions tests/func/test_import_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import pytest

from dvc.dependency.base import DependencyDoesNotExistError
from dvc.main import main
from dvc.stage import Stage
from dvc.utils.fs import makedirs
Expand Down Expand Up @@ -97,3 +98,8 @@ def test_import_stage_accompanies_target(tmp_dir, dvc, erepo_dir):

assert (tmp_dir / "dir" / "imported_file").exists()
assert (tmp_dir / "dir" / "imported_file.dvc").exists()


def test_import_url_nonexistent(dvc, erepo_dir):
with pytest.raises(DependencyDoesNotExistError):
dvc.imp_url(os.fspath(erepo_dir / "non-existent"))