diff --git a/dvc/remote/base.py b/dvc/remote/base.py index 050c16659..88c52fbd3 100644 --- a/dvc/remote/base.py +++ b/dvc/remote/base.py @@ -116,7 +116,7 @@ class RemoteBASE(object): ) self.protected = False - self.no_traverse = config.get(Config.SECTION_REMOTE_NO_TRAVERSE) + self.no_traverse = config.get(Config.SECTION_REMOTE_NO_TRAVERSE, True) self._dir_info = {} def __repr__(self): diff --git a/dvc/remote/http.py b/dvc/remote/http.py index f377f0ddc..300d0f896 100644 --- a/dvc/remote/http.py +++ b/dvc/remote/http.py @@ -10,7 +10,7 @@ import logging from dvc.progress import progress from dvc.exceptions import DvcException -from dvc.config import Config +from dvc.config import Config, ConfigError from dvc.remote.base import RemoteBASE @@ -42,6 +42,12 @@ class RemoteHTTP(RemoteBASE): url = config.get(Config.SECTION_REMOTE_URL) self.path_info = self.path_cls(url) if url else None + if not self.no_traverse: + raise ConfigError( + "HTTP doesn't support traversing the remote to list existing " + "files. Use: `dvc remote modify no_traverse true`" + ) + def _download(self, from_info, to_file, name=None, no_progress_bar=False): callback = None if not no_progress_bar: diff --git a/tests/func/test_data_cloud.py b/tests/func/test_data_cloud.py index f7bf341fd..780755c73 100644 --- a/tests/func/test_data_cloud.py +++ b/tests/func/test_data_cloud.py @@ -457,6 +457,21 @@ class TestRemoteSSHMocked(TestDataCloudBase): self.ssh_server = ssh_server self.method_name = request.function.__name__ + def _setup_cloud(self): + self._ensure_should_run() + + repo = self._get_url() + keyfile = self._get_keyfile() + + config = copy.deepcopy(TEST_CONFIG) + config[TEST_SECTION][Config.SECTION_REMOTE_URL] = repo + config[TEST_SECTION][Config.SECTION_REMOTE_KEY_FILE] = keyfile + config[TEST_SECTION][Config.SECTION_REMOTE_NO_TRAVERSE] = False + self.dvc.config.config = config + self.cloud = DataCloud(self.dvc) + + self.assertIsInstance(self.cloud.get_remote(), self._get_cloud_class()) + def _get_url(self): user = self.ssh_server.test_creds["username"] return get_ssh_url_mocked(user, self.ssh_server.port) diff --git a/tests/unit/remote/test_http.py b/tests/unit/remote/test_http.py new file mode 100644 index 000000000..b2d82bd8e --- /dev/null +++ b/tests/unit/remote/test_http.py @@ -0,0 +1,14 @@ +import pytest +from dvc.remote.http import RemoteHTTP +from dvc.config import ConfigError + + +def test_no_traverse_compatibility(dvc_repo): + config = { + "url": "http://example.com/", + "path_info": "file.html", + "no_traverse": False, + } + + with pytest.raises(ConfigError): + RemoteHTTP(dvc_repo, config)