Skip to content

Commit

Permalink
dvc: move 'verify' property from tree to cache (iterative#5334)
Browse files Browse the repository at this point in the history
  • Loading branch information
efiop authored Jan 26, 2021
1 parent 6a1f365 commit 8112ce3
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions dvc/cache/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

def get_cloud_cache(tree):
from .base import CloudCache
from .gdrive import GDriveCache
from .local import LocalCache
from .ssh import SSHCache

Expand All @@ -15,6 +16,9 @@ def get_cloud_cache(tree):
if tree.scheme == Schemes.SSH:
return SSHCache(tree)

if tree.scheme == Schemes.GDRIVE:
return GDriveCache(tree)

return CloudCache(tree)


Expand Down
2 changes: 2 additions & 0 deletions dvc/cache/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ def use_state(call):

class CloudCache:

DEFAULT_VERIFY = False
DEFAULT_CACHE_TYPES = ["copy"]
CACHE_MODE: Optional[int] = None

def __init__(self, tree):
self.tree = tree
self.repo = tree.repo

self.verify = tree.config.get("verify", self.DEFAULT_VERIFY)
self.cache_types = tree.config.get("type") or copy(
self.DEFAULT_CACHE_TYPES
)
Expand Down
5 changes: 5 additions & 0 deletions dvc/cache/gdrive.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .base import CloudCache


class GDriveCache(CloudCache):
DEFAULT_VERIFY = True
2 changes: 1 addition & 1 deletion dvc/remote/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ def pull(self, cache, named_cache, jobs=None, show_checksums=False):
download=True,
)

if not self.tree.verify:
if not self.cache.verify:
with cache.tree.state:
for checksum in named_cache.scheme_keys("local"):
cache_file = cache.tree.hash_to_path_info(checksum)
Expand Down
2 changes: 0 additions & 2 deletions dvc/tree/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class BaseTree:

CHECKSUM_DIR_SUFFIX = ".dir"
HASH_JOBS = max(1, min(4, cpu_count() // 2))
DEFAULT_VERIFY = False
LIST_OBJECT_PAGE_SIZE = 1000
TRAVERSE_WEIGHT_MULTIPLIER = 5
TRAVERSE_PREFIX_LEN = 3
Expand All @@ -71,7 +70,6 @@ def __init__(self, repo, config):

self._check_requires()

self.verify = config.get("verify", self.DEFAULT_VERIFY)
self.path_info = None

@cached_property
Expand Down
1 change: 0 additions & 1 deletion dvc/tree/gdrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ class GDriveTree(BaseTree):
scheme = Schemes.GDRIVE
PATH_CLS = GDriveURLInfo
REQUIRES = {"pydrive2": "pydrive2"}
DEFAULT_VERIFY = True
# Always prefer traverse for GDrive since API usage quotas are a concern.
TRAVERSE_WEIGHT_MULTIPLIER = 1
TRAVERSE_PREFIX_LEN = 2
Expand Down

0 comments on commit 8112ce3

Please sign in to comment.