Skip to content
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
2 changes: 2 additions & 0 deletions dvc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ class Config(object): # pylint: disable=too-many-instance-attributes
SECTION_GDRIVE_CLIENT_SECRET = "gdrive_client_secret"
SECTION_GDRIVE_USER_CREDENTIALS_FILE = "gdrive_user_credentials_file"

SECTION_REMOTE_CHECKSUM_JOBS = "checksum_jobs"
SECTION_REMOTE_REGEX = r'^\s*remote\s*"(?P<name>.*)"\s*$'
SECTION_REMOTE_FMT = 'remote "{}"'
SECTION_REMOTE_URL = "url"
Expand Down Expand Up @@ -214,6 +215,7 @@ class Config(object): # pylint: disable=too-many-instance-attributes
SECTION_GCP_PROJECTNAME: str,
SECTION_CACHE_TYPE: supported_cache_type,
Optional(SECTION_CACHE_PROTECTED, default=False): Bool,
SECTION_REMOTE_CHECKSUM_JOBS: All(Coerce(int), Range(1)),
SECTION_REMOTE_USER: str,
SECTION_REMOTE_PORT: Coerce(int),
SECTION_REMOTE_KEY_FILE: str,
Expand Down
19 changes: 14 additions & 5 deletions dvc/remote/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,7 @@ def __init__(self, repo, config):
self.repo = repo

self._check_requires(config)

core = config.get(Config.SECTION_CORE, {})
self.checksum_jobs = core.get(
Config.SECTION_CORE_CHECKSUM_JOBS, self.CHECKSUM_JOBS
)
self.checksum_jobs = self._get_checksum_jobs(config)

self.protected = False
self.no_traverse = config.get(Config.SECTION_REMOTE_NO_TRAVERSE, True)
Expand Down Expand Up @@ -142,6 +138,19 @@ def _check_requires(self, config):
).format(url, missing, " ".join(missing), self.scheme)
raise RemoteMissingDepsError(msg)

def _get_checksum_jobs(self, config):
checksum_jobs = config.get(Config.SECTION_REMOTE_CHECKSUM_JOBS)
if checksum_jobs:
return checksum_jobs

if self.repo:
core = self.repo.config.config.get(Config.SECTION_CORE, {})
return core.get(
Config.SECTION_CORE_CHECKSUM_JOBS, self.CHECKSUM_JOBS
)

return self.CHECKSUM_JOBS

def __repr__(self):
return "{class_name}: '{path_info}'".format(
class_name=type(self).__name__,
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/remote/test_gdrive.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest
import os

from dvc.config import Config
from dvc.remote.gdrive import (
RemoteGDrive,
GDriveAccessTokenRefreshError,
Expand All @@ -14,6 +15,7 @@

class Repo(object):
tmp_dir = ""
config = Config()


class TestRemoteGDrive(object):
Expand Down
41 changes: 41 additions & 0 deletions tests/unit/remote/test_remote.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from dvc.remote import Remote


def set_config_opts(dvc, commands):
list(map(lambda args: dvc.config.set(*args), commands))


def test_remote_with_checksum_jobs(dvc):
set_config_opts(
dvc,
[
('remote "with_checksum_jobs"', "url", "s3://bucket/name"),
('remote "with_checksum_jobs"', "checksum_jobs", 100),
("core", "checksum_jobs", 200),
],
)

remote = Remote(dvc, name="with_checksum_jobs")
assert remote.checksum_jobs == 100


def test_remote_without_checksum_jobs(dvc):
set_config_opts(
dvc,
[
('remote "without_checksum_jobs"', "url", "s3://bucket/name"),
("core", "checksum_jobs", "200"),
],
)

remote = Remote(dvc, name="without_checksum_jobs")
assert remote.checksum_jobs == 200


def test_remote_without_checksum_jobs_default(dvc):
set_config_opts(
dvc, [('remote "without_checksum_jobs"', "url", "s3://bucket/name")]
)

remote = Remote(dvc, name="without_checksum_jobs")
assert remote.checksum_jobs == remote.CHECKSUM_JOBS