mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
http: add exception when trying to traverse remote (#2411)
* http: add exception when trying to traverse remote Fix #2380 * http: exception raise on `list_cache_paths` instead of `all` `NotImplementedError` -> `RemoteActionNotImplemented` * http: raise exception on `__init__` * set default no_traverse to True on remote base * tests: explicitly use traverse on data cloud and no traverse with HTTP * remote: define a new RemoteConfigError * remote: reuse ConfigError instead of RemoteConfigError * tests: set no_traverse to False with SSHMocked * deepsource: fix minor issue with spacing * remove blankspace Co-Authored-By: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
committed by
Ruslan Kuprieiev
co-authored by
Ruslan Kuprieiev
parent
51d5a230da
commit
8918bdc383
+1
-1
@@ -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):
|
||||
|
||||
+7
-1
@@ -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 <name> no_traverse true`"
|
||||
)
|
||||
|
||||
def _download(self, from_info, to_file, name=None, no_progress_bar=False):
|
||||
callback = None
|
||||
if not no_progress_bar:
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
Reference in New Issue
Block a user