mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-27 07:18:28 +01:00
dvc: dynamically load default cloud
Fixes #1390 Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
committed by
Ruslan Kuprieiev
parent
ff577d7a87
commit
75ab3074a1
+12
-11
@@ -27,18 +27,19 @@ class DataCloud(object):
|
||||
self._config = config
|
||||
self._core = self._config[Config.SECTION_CORE]
|
||||
|
||||
@property
|
||||
def _cloud(self):
|
||||
remote = self._core.get(Config.SECTION_CORE_REMOTE, '')
|
||||
if remote == '':
|
||||
if self._core.get(Config.SECTION_CORE_CLOUD, None):
|
||||
# backward compatibility
|
||||
msg = 'Using obsoleted config format. Consider updating.'
|
||||
Logger.warn(msg)
|
||||
self._cloud = self.__init__compat()
|
||||
else:
|
||||
self._cloud = None
|
||||
return
|
||||
if remote != '':
|
||||
return self._init_remote(remote)
|
||||
|
||||
self._cloud = self._init_remote(remote)
|
||||
if self._core.get(Config.SECTION_CORE_CLOUD, None):
|
||||
# backward compatibility
|
||||
msg = 'Using obsoleted config format. Consider updating.'
|
||||
Logger.warn(msg)
|
||||
return self._init_compat()
|
||||
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def supported(config):
|
||||
@@ -60,7 +61,7 @@ class DataCloud(object):
|
||||
|
||||
return self._init_cloud(cloud_config, cloud_type)
|
||||
|
||||
def __init__compat(self):
|
||||
def _init_compat(self):
|
||||
name = self._core.get(Config.SECTION_CORE_CLOUD, '').strip().lower()
|
||||
if name == '':
|
||||
self._cloud = None
|
||||
|
||||
@@ -175,11 +175,15 @@ class TestDataCloud(TestDvc):
|
||||
self._test_cloud(config, cl)
|
||||
|
||||
def test_unsupported(self):
|
||||
remote_url = 'notsupportedscheme://a/b'
|
||||
config = TEST_CONFIG
|
||||
config[TEST_SECTION][Config.SECTION_REMOTE_URL] = remote_url
|
||||
|
||||
# NOTE: making sure that error doesn't raise too early
|
||||
cloud = DataCloud(self.dvc, config=config)
|
||||
|
||||
with self.assertRaises(ConfigError):
|
||||
remote_url = 'notsupportedscheme://a/b'
|
||||
config = TEST_CONFIG
|
||||
config[TEST_SECTION][Config.SECTION_REMOTE_URL] = remote_url
|
||||
DataCloud(self.dvc, config=config)
|
||||
cloud._cloud
|
||||
|
||||
|
||||
class TestDataCloudBase(TestDvc):
|
||||
|
||||
Reference in New Issue
Block a user