Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jan 26, 2021
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
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