docs: add some docstrings about computing status (#2048)

This commit is contained in:
Mr. Outis
2019-05-23 16:16:02 -07:00
committed by GitHub
parent 6569657390
commit 037f32c8cc
3 changed files with 78 additions and 0 deletions
+11
View File
@@ -503,6 +503,17 @@ class RemoteBASE(object):
return removed
def changed_cache_file(self, checksum):
"""Compare the given checksum with the (corresponding) actual one.
- Use `State` as a cache for computed checksums
+ The entries are invalidated by taking into account the following:
* mtime
* inode
* size
* checksum
- Remove the file from cache if it doesn't match the actual checksum
"""
cache_info = self.checksum_to_path_info(checksum)
actual = self.get_checksum(cache_info)
+41
View File
@@ -176,6 +176,26 @@ class Repo(object):
def _collect_dir_cache(
self, out, branch=None, remote=None, force=False, jobs=None
):
"""Get a list of `info`s retaled to the given directory.
- Pull the directory entry from the remote cache if it was changed.
Example:
Given the following commands:
$ echo "foo" > directory/foo
$ echo "bar" > directory/bar
$ dvc add directory
It will return something similar to the following list:
[
{ 'path': 'directory', 'md5': '168fd6761b9c.dir', ... },
{ 'path': 'directory/foo', 'md5': 'c157a79031e1', ... },
{ 'path': 'directory/bar', 'md5': 'd3b07384d113', ... },
]
"""
info = out.dumpd()
ret = [info]
r = out.remote
@@ -216,6 +236,13 @@ class Repo(object):
def _collect_used_cache(
self, out, branch=None, remote=None, force=False, jobs=None
):
"""Get a dumpd of the given `out`, with an entry including the branch.
The `used_cache` of an output is no more than its `info`.
In case that the given output is a directory, it will also
include the `info` of its files.
"""
if not out.use_cache or not out.info:
if not out.info:
logger.warning(
@@ -252,6 +279,20 @@ class Repo(object):
jobs=None,
recursive=False,
):
"""Get the stages related to the given target and collect
the `info` of its outputs.
This is useful to know what files from the cache are _in use_
(namely, a file described as an output on a stage).
The scope is, by default, the working directory, but you can use
`all_branches` or `all_tags` to expand scope.
Returns:
A dictionary with Schemes (representing output's location) as keys,
and a list with the outputs' `dumpd` as values.
"""
cache = {}
cache["local"] = []
cache["s3"] = []
+26
View File
@@ -35,6 +35,32 @@ def _cloud_status(
with_deps=False,
all_tags=False,
):
"""Returns a dictionary with the files that are new or deleted.
- new: Remote doesn't have the file
- deleted: File is no longer in the local cache
Example:
Given the following commands:
$ echo "foo" > foo
$ echo "bar" > bar
$ dvc add foo bar
$ dvc status -c
It will return something like:
{ "foo": "new", "bar": "new" }
Now, after pushing and removing "bar" from the local cache:
$ dvc push
$ rm .dvc/cache/c1/57a79031e1c40f85931829bc5fc552
The result would be:
{ "bar": "deleted" }
"""
import dvc.remote.base as cloud
used = self.used_cache(