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
19 changes: 16 additions & 3 deletions dvc/cache/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def status(
jobs=None,
show_checksums=False,
download=False,
log_missing=True,
Copy link
Contributor

Choose a reason for hiding this comment

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

We've been thinking about revisit logging/info interface for a long time, since passing a chain of such flags is not the prettiest thing ever 🙁 But there is no simple better way for now, so this will work for now 👍

):
# Return flattened dict containing all status info
dir_status, file_status, _ = self._status(
Expand All @@ -122,6 +123,7 @@ def status(
jobs=jobs,
show_checksums=show_checksums,
download=download,
log_missing=log_missing,
)
return dict(dir_status, **file_status)

Expand All @@ -132,6 +134,7 @@ def _status(
jobs=None,
show_checksums=False,
download=False,
log_missing=True,
):
"""Return a tuple of (dir_status_info, file_status_info, dir_contents).

Expand Down Expand Up @@ -172,11 +175,20 @@ def _status(
)
)
return self._make_status(
named_cache, show_checksums, local_exists, remote_exists
named_cache,
show_checksums,
local_exists,
remote_exists,
log_missing,
)

def _make_status(
self, named_cache, show_checksums, local_exists, remote_exists
self,
named_cache,
show_checksums,
local_exists,
remote_exists,
log_missing,
):
def make_names(hash_, names):
return {"name": hash_ if show_checksums else " ".join(names)}
Expand All @@ -199,7 +211,8 @@ def make_names(hash_, names):
self._fill_statuses(dir_status, local_exists, remote_exists)
self._fill_statuses(file_status, local_exists, remote_exists)

self._log_missing_caches(dict(dir_status, **file_status))
if log_missing:
self._log_missing_caches(dict(dir_status, **file_status))

return dir_status, file_status, dir_contents

Expand Down
17 changes: 15 additions & 2 deletions dvc/data_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,14 @@ def _save_pulled_checksums(self, cache):
# (see `RemoteBASE.download()`)
self.repo.state.save(cache_file, checksum)

def status(self, cache, jobs=None, remote=None, show_checksums=False):
def status(
self,
cache,
jobs=None,
remote=None,
show_checksums=False,
log_missing=True,
):
"""Check status of data items in a cloud-agnostic way.

Args:
Expand All @@ -111,8 +118,14 @@ def status(self, cache, jobs=None, remote=None, show_checksums=False):
is used.
show_checksums (bool): show checksums instead of file names in
information messages.
log_missing (bool): log warning messages if file doesn't exist
neither in cache, neither in cloud.
"""
remote = self.get_remote(remote, "status")
return self.repo.cache.local.status(
cache, jobs=jobs, remote=remote, show_checksums=show_checksums
cache,
jobs=jobs,
remote=remote,
show_checksums=show_checksums,
log_missing=log_missing,
)
5 changes: 4 additions & 1 deletion dvc/repo/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def _cloud_status(

- new: Remote doesn't have the file
- deleted: File is no longer in the local cache
- missing: File doesn't exist neither in the cache, neither in remote

Example:
Given the following commands:
Expand Down Expand Up @@ -90,7 +91,9 @@ def _cloud_status(
)

ret = {}
status_info = self.cloud.status(used, jobs, remote=remote)
status_info = self.cloud.status(
used, jobs, remote=remote, log_missing=False
)
for info in status_info.values():
name = info["name"]
status_ = info["status"]
Expand Down
8 changes: 4 additions & 4 deletions tests/func/test_data_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,10 @@ def test_missing_cache(tmp_dir, dvc, local_remote, caplog):
assert bar in caplog.text

caplog.clear()
dvc.status(cloud=True)
assert header in caplog.text
assert foo in caplog.text
assert bar in caplog.text
assert dvc.status(cloud=True) == {"bar": "missing", "foo": "missing"}
assert header not in caplog.text
assert foo not in caplog.text
assert bar not in caplog.text


def test_verify_hashes(
Expand Down