Skip to content

Commit

Permalink
gdrive: allow configuring no_traverse
Browse files Browse the repository at this point in the history
  • Loading branch information
efiop committed Jan 20, 2020
1 parent 39bf7c0 commit e848bcb
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dvc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ class Config(object): # pylint: disable=too-many-instance-attributes
SECTION_GDRIVE_CLIENT_SECRET: str,
SECTION_GDRIVE_USER_CREDENTIALS_FILE: str,
PRIVATE_CWD: str,
Optional(SECTION_REMOTE_NO_TRAVERSE, default=True): Bool,
SECTION_REMOTE_NO_TRAVERSE: Bool,
}

SECTION_STATE = "state"
Expand Down
5 changes: 4 additions & 1 deletion dvc/remote/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class RemoteBASE(object):
CHECKSUM_DIR_SUFFIX = ".dir"
CHECKSUM_JOBS = max(1, min(4, cpu_count() // 2))
DEFAULT_CACHE_TYPES = ["copy"]
DEFAULT_NO_TRAVERSE = True

state = StateNoop()

Expand All @@ -89,7 +90,9 @@ def __init__(self, repo, config):
self.checksum_jobs = self._get_checksum_jobs(config)

self.protected = False
self.no_traverse = config.get(Config.SECTION_REMOTE_NO_TRAVERSE, True)
self.no_traverse = config.get(
Config.SECTION_REMOTE_NO_TRAVERSE, self.DEFAULT_NO_TRAVERSE
)
self._dir_info = {}

types = config.get(Config.SECTION_CACHE_TYPE, None)
Expand Down
3 changes: 2 additions & 1 deletion dvc/remote/gdrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,13 @@ class RemoteGDrive(RemoteBASE):
scheme = Schemes.GDRIVE
path_cls = CloudURLInfo
REQUIRES = {"pydrive2": "pydrive2"}
DEFAULT_NO_TRAVERSE = False

GDRIVE_USER_CREDENTIALS_DATA = "GDRIVE_USER_CREDENTIALS_DATA"
DEFAULT_USER_CREDENTIALS_FILE = "gdrive-user-credentials.json"

def __init__(self, repo, config):
super().__init__(repo, config)
self.no_traverse = False
self.path_info = self.path_cls(config[Config.SECTION_REMOTE_URL])

bucket = re.search(
Expand Down
1 change: 1 addition & 0 deletions tests/unit/remote/test_gdrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class TestRemoteGDrive(object):
def test_init(self):
remote = RemoteGDrive(Repo(), self.CONFIG)
assert str(remote.path_info) == self.CONFIG["url"]
assert not remote.no_traverse

def test_drive(self):
remote = RemoteGDrive(Repo(), self.CONFIG)
Expand Down
16 changes: 16 additions & 0 deletions tests/unit/test_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from dvc.config import Config


def test_remote_config_no_traverse():
d = Config.COMPILED_SCHEMA({'remote "myremote"': {"url": "url"}})
assert "no_traverse" not in d['remote "myremote"']

d = Config.COMPILED_SCHEMA(
{'remote "myremote"': {"url": "url", "no_traverse": "fAlSe"}}
)
assert not d['remote "myremote"']["no_traverse"]

d = Config.COMPILED_SCHEMA(
{'remote "myremote"': {"url": "url", "no_traverse": "tRuE"}}
)
assert d['remote "myremote"']["no_traverse"]

0 comments on commit e848bcb

Please sign in to comment.