Merge pull request #3201 from efiop/traverse_gdrive

gdrive: allow configuring no_traverse
This commit is contained in:
Ruslan Kuprieiev
2020-01-21 00:19:11 +02:00
committed by GitHub
5 changed files with 24 additions and 3 deletions
+1 -1
View File
@@ -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"
+4 -1
View File
@@ -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()
@@ -89,7 +90,9 @@ class RemoteBASE(object):
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)
+2 -1
View File
@@ -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(
+1
View File
@@ -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)
+16
View File
@@ -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"]