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
5 changes: 4 additions & 1 deletion dvc/dependency/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def _get_checksum(self, locked=True):
return self.repo.cache.local.tree.get_hash(path, tree=tree)
return tree.get_file_hash(path)

def status(self):
def workspace_status(self):
current_checksum = self._get_checksum(locked=True)
updated_checksum = self._get_checksum(locked=False)

Comment on lines 70 to 73
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This status hack backfired a bit. Need to set self.tree properly here (it will pretty much be RepoTree for the external repo that this belongs to), so that things like self.exists() work automatically.

Expand All @@ -76,6 +76,9 @@ def status(self):

return {}

def status(self):
return self.workspace_status()

def save(self):
pass

Expand Down
12 changes: 8 additions & 4 deletions dvc/output/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,7 @@ def changed_cache(self, filter_info=None):

return self.cache.changed_cache(self.checksum, filter_info=filter_info)

def status(self):
if self.checksum and self.use_cache and self.changed_cache():
return {str(self): "not in cache"}

def workspace_status(self):
if not self.exists:
return {str(self): "deleted"}

Expand All @@ -214,6 +211,12 @@ def status(self):

return {}

def status(self):
if self.checksum and self.use_cache and self.changed_cache():
return {str(self): "not in cache"}

return self.workspace_status()

def changed(self):
status = self.status()
logger.debug(str(status))
Expand Down Expand Up @@ -280,6 +283,7 @@ def save(self):
self.info = self.save_info()

def commit(self):
assert self.info
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added this because https://github.com/iterative/dvc/blob/2f48bb4089c25c2144fa3c9d9d8d0ba69c4c3e51/dvc/cache/base.py#L280 shouldn't be there, really. It is a leftover from erepo/tree hacks we used to have, but some code is still using it, so need to get back to it in a separate PR.

if self.use_cache:
self.cache.save(self.path_info, self.cache.tree, self.info)

Expand Down
2 changes: 1 addition & 1 deletion dvc/stage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ def ignore_outs(self):

@staticmethod
def _changed_entries(entries):
return [str(entry) for entry in entries if entry.changed_checksum()]
return [str(entry) for entry in entries if entry.workspace_status()]

def _changed_stage_entry(self):
return f"'md5' of {self} changed."
Expand Down
20 changes: 20 additions & 0 deletions tests/func/test_commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import pytest

from dvc.dependency.base import DependencyDoesNotExistError
from dvc.dvcfile import PIPELINE_FILE
from dvc.output.base import OutputDoesNotExistError
from dvc.stage.exceptions import StageCommitError
from dvc.utils.yaml import dump_yaml, load_yaml

Expand Down Expand Up @@ -86,6 +88,24 @@ def test_commit_no_exec(tmp_dir, dvc):
assert dvc.status(stage.path) == {}


def test_commit_no_exec_missing_dep(tmp_dir, dvc):
stage = dvc.run(
name="my", cmd="mycmd", deps=["dep"], outs=["out"], no_exec=True
)
assert dvc.status(stage.path)

with pytest.raises(DependencyDoesNotExistError):
dvc.commit(stage.path, force=True)


def test_commit_no_exec_missing_out(tmp_dir, dvc):
stage = dvc.run(name="my", cmd="mycmd", outs=["out"], no_exec=True)
assert dvc.status(stage.path)

with pytest.raises(OutputDoesNotExistError):
dvc.commit(stage.path, force=True)


def test_commit_pipeline_stage(tmp_dir, dvc, run_copy):
tmp_dir.gen("foo", "foo")
stage = run_copy("foo", "bar", no_commit=True, name="copy-foo-bar")
Expand Down