From a585613b905ebe2d123d35e4982833609430d098 Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Tue, 26 Jan 2021 01:27:38 +0200 Subject: [PATCH] dvc: move 'verify' property from tree to cache --- dvc/cache/__init__.py | 4 ++++ dvc/cache/base.py | 2 ++ dvc/cache/gdrive.py | 5 +++++ dvc/remote/base.py | 2 +- dvc/tree/base.py | 2 -- dvc/tree/gdrive.py | 1 - 6 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 dvc/cache/gdrive.py diff --git a/dvc/cache/__init__.py b/dvc/cache/__init__.py index b9e7dd95a8..512778fa99 100644 --- a/dvc/cache/__init__.py +++ b/dvc/cache/__init__.py @@ -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 @@ -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) diff --git a/dvc/cache/base.py b/dvc/cache/base.py index 2fcbb3858f..d0bc7650fe 100644 --- a/dvc/cache/base.py +++ b/dvc/cache/base.py @@ -45,6 +45,7 @@ def use_state(call): class CloudCache: + DEFAULT_VERIFY = False DEFAULT_CACHE_TYPES = ["copy"] CACHE_MODE: Optional[int] = None @@ -52,6 +53,7 @@ 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 ) diff --git a/dvc/cache/gdrive.py b/dvc/cache/gdrive.py new file mode 100644 index 0000000000..7cf1f5275a --- /dev/null +++ b/dvc/cache/gdrive.py @@ -0,0 +1,5 @@ +from .base import CloudCache + + +class GDriveCache(CloudCache): + DEFAULT_VERIFY = True diff --git a/dvc/remote/base.py b/dvc/remote/base.py index fa3263dbc6..934ed48d05 100644 --- a/dvc/remote/base.py +++ b/dvc/remote/base.py @@ -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) diff --git a/dvc/tree/base.py b/dvc/tree/base.py index a95e320711..6bbb36c6d2 100644 --- a/dvc/tree/base.py +++ b/dvc/tree/base.py @@ -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 @@ -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 diff --git a/dvc/tree/gdrive.py b/dvc/tree/gdrive.py index 2007f8d156..9bdcbdec3e 100644 --- a/dvc/tree/gdrive.py +++ b/dvc/tree/gdrive.py @@ -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