diff --git a/dvc/config.py b/dvc/config.py index 0fd312aa14..65250c76de 100644 --- a/dvc/config.py +++ b/dvc/config.py @@ -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" diff --git a/dvc/remote/base.py b/dvc/remote/base.py index 4b6a8a5aa1..788742c8c1 100644 --- a/dvc/remote/base.py +++ b/dvc/remote/base.py @@ -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 @@ 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) diff --git a/dvc/remote/gdrive.py b/dvc/remote/gdrive.py index aa87f1bbd0..a38b2a1a2b 100644 --- a/dvc/remote/gdrive.py +++ b/dvc/remote/gdrive.py @@ -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( diff --git a/tests/unit/remote/test_gdrive.py b/tests/unit/remote/test_gdrive.py index 09dc7e62b6..9d7c511e18 100644 --- a/tests/unit/remote/test_gdrive.py +++ b/tests/unit/remote/test_gdrive.py @@ -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) diff --git a/tests/unit/test_config.py b/tests/unit/test_config.py new file mode 100644 index 0000000000..e5537c6374 --- /dev/null +++ b/tests/unit/test_config.py @@ -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"]