Merge pull request #2290 from pared/2221

data_cloud: remove backward compatibilty on get_remote
This commit is contained in:
Ruslan Kuprieiev
2019-07-18 14:10:50 +03:00
committed by GitHub
7 changed files with 0 additions and 105 deletions
-12
View File
@@ -181,15 +181,6 @@ class Config(object): # pylint: disable=too-many-instance-attributes
Optional(SECTION_CACHE_SLOW_LINK_WARNING, default=True): BOOL_SCHEMA,
}
# backward compatibility
SECTION_CORE_CLOUD = "cloud"
SECTION_CORE_CLOUD_SCHEMA = And(
Use(str.lower),
# only the clouds which were supported by obsoleted cloud config
Choices("aws", "gcp", "local", ""),
)
SECTION_CORE_STORAGEPATH = "storagepath"
SECTION_CORE_SCHEMA = {
Optional(SECTION_CORE_LOGLEVEL): And(
str, Use(str.lower), SECTION_CORE_LOGLEVEL_SCHEMA
@@ -204,9 +195,6 @@ class Config(object): # pylint: disable=too-many-instance-attributes
Optional(
SECTION_CORE_CHECKSUM_JOBS, default=None
): SECTION_CORE_CHECKSUM_JOBS_SCHEMA,
# backward compatibility
Optional(SECTION_CORE_CLOUD, default=""): SECTION_CORE_CLOUD_SCHEMA,
Optional(SECTION_CORE_STORAGEPATH, default=""): str,
}
# backward compatibility
-36
View File
@@ -60,12 +60,6 @@ class DataCloud(object):
if remote:
return self._init_remote(remote)
# Old config format support for backward compatibility
if Config.SECTION_CORE_CLOUD in self._core:
msg = "using obsoleted config format. Consider updating."
logger.warning(msg)
return self._init_compat()
raise ConfigError(
"No remote repository specified. Setup default repository with\n"
" dvc config core.remote <name>\n"
@@ -76,36 +70,6 @@ class DataCloud(object):
def _init_remote(self, remote):
return Remote(self.repo, name=remote)
def _init_compat(self):
name = self._core.get(Config.SECTION_CORE_CLOUD, "").strip().lower()
if name == "":
return None
cloud_type = self.CLOUD_MAP.get(name, None)
if not cloud_type:
msg = "wrong cloud type '{}' specified".format(name)
raise ConfigError(msg)
cloud_config = self._config.get(name, None)
if not cloud_config:
msg = "can't find cloud section '{}' in config".format(name)
raise ConfigError(msg)
# NOTE: check if the class itself has everything needed for operation.
# E.g. all the imported packages.
if not cloud_type.supported(cloud_type.compat_config(cloud_config)):
raise ConfigError("unsupported cloud '{}'".format(name))
return self._init_cloud(cloud_config, cloud_type)
def _init_cloud(self, cloud_config, cloud_type):
global_storage_path = self._core.get(Config.SECTION_CORE_STORAGEPATH)
if global_storage_path:
logger.warning("using obsoleted config format. Consider updating.")
cloud = cloud_type(self.repo, cloud_config)
return cloud
def push(self, targets, jobs=None, remote=None, show_checksums=False):
"""Push data items in a cloud-agnostic way.
-3
View File
@@ -124,9 +124,6 @@ class RemoteBASE(object):
path_info=self.path_info or "No path",
)
def compat_config(config):
return config.copy()
@classmethod
def supported(cls, config):
if isinstance(config, basestring):
-7
View File
@@ -35,13 +35,6 @@ class RemoteGS(RemoteBASE):
self.projectname = config.get(Config.SECTION_GCP_PROJECTNAME, None)
self.credentialpath = config.get(Config.SECTION_GCP_CREDENTIALPATH)
@staticmethod
def compat_config(config):
ret = config.copy()
url = "gs://" + ret.pop(Config.SECTION_GCP_STORAGEPATH, "").lstrip("/")
ret[Config.SECTION_REMOTE_URL] = url
return ret
@cached_property
def gs(self):
return (
-7
View File
@@ -91,13 +91,6 @@ class RemoteLOCAL(RemoteBASE):
def supported(cls, config):
return True
@staticmethod
def compat_config(config):
ret = config.copy()
url = ret.pop(Config.SECTION_LOCAL_STORAGEPATH, "")
ret[Config.SECTION_REMOTE_URL] = url
return ret
def list_cache_paths(self):
assert self.path_info is not None
-7
View File
@@ -70,13 +70,6 @@ class RemoteS3(RemoteBASE):
if shared_creds:
os.environ.setdefault("AWS_SHARED_CREDENTIALS_FILE", shared_creds)
@staticmethod
def compat_config(config):
ret = config.copy()
url = "s3://" + ret.pop(Config.SECTION_AWS_STORAGEPATH, "").lstrip("/")
ret[Config.SECTION_REMOTE_URL] = url
return ret
@cached_property
def s3(self):
session = boto3.session.Session(
-33
View File
@@ -568,15 +568,6 @@ class TestDataCloudCLIBase(TestDvc):
self._test()
class TestCompatRemoteLOCALCLI(TestDataCloudCLIBase):
def _test(self):
storagepath = get_local_storagepath()
self.main(["config", "core.cloud", "local"])
self.main(["config", "local.storagepath", storagepath])
self._test_cloud()
class TestRemoteLOCALCLI(TestDataCloudCLIBase):
def _test(self):
url = get_local_url()
@@ -610,18 +601,6 @@ class TestRemoteHDFSCLI(TestDataCloudCLIBase):
self._test_cloud(TEST_REMOTE)
class TestCompatRemoteS3CLI(TestDataCloudCLIBase):
def _should_test(self):
return _should_test_aws()
def _test(self):
storagepath = get_aws_storagepath()
self.main(["config", "core.cloud", "aws"])
self.main(["config", "aws.storagepath", storagepath])
self._test_cloud()
class TestRemoteS3CLI(TestDataCloudCLIBase):
def _should_test(self):
return _should_test_aws()
@@ -634,18 +613,6 @@ class TestRemoteS3CLI(TestDataCloudCLIBase):
self._test_cloud(TEST_REMOTE)
class TestCompatRemoteGSCLI(TestDataCloudCLIBase):
def _should_test(self):
return _should_test_gcp()
def _test(self):
storagepath = get_gcp_storagepath()
self.main(["config", "core.cloud", "gcp"])
self.main(["config", "gcp.storagepath", storagepath])
self._test_cloud()
class TestRemoteGSCLI(TestDataCloudCLIBase):
def _should_test(self):
return _should_test_gcp()