dvc: move 'verify' property from tree to cache (#5334)

This commit is contained in:
Ruslan Kuprieiev
2021-01-26 02:00:35 +02:00
committed by GitHub
parent 6a1f3659f5
commit 8112ce36d1
6 changed files with 12 additions and 4 deletions
+4
View File
@@ -6,6 +6,7 @@ from ..scheme import Schemes
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)
+2
View File
@@ -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 @@ class CloudCache:
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
)
+5
View File
@@ -0,0 +1,5 @@
from .base import CloudCache
class GDriveCache(CloudCache):
DEFAULT_VERIFY = True
+1 -1
View File
@@ -481,7 +481,7 @@ class Remote:
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)
-2
View File
@@ -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 @@ class BaseTree:
self._check_requires()
self.verify = config.get("verify", self.DEFAULT_VERIFY)
self.path_info = None
@cached_property
-1
View File
@@ -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