diff --git a/dvc/data_cloud.py b/dvc/data_cloud.py index 771c6a3e9..bb12acdff 100644 --- a/dvc/data_cloud.py +++ b/dvc/data_cloud.py @@ -73,6 +73,11 @@ class DataCloud(object): msg = "Can't find cloud section '{}' in config" raise ConfigError(msg.format(name)) + # 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): diff --git a/dvc/remote/base.py b/dvc/remote/base.py index cd3991300..c4cc47f91 100644 --- a/dvc/remote/base.py +++ b/dvc/remote/base.py @@ -36,10 +36,13 @@ class RemoteBase(object): def __init__(self, project, config): pass + def compat_config(config): + return config.copy() + @classmethod def supported(cls, config): url = config[Config.SECTION_REMOTE_URL] - url_ok = cls.match(url) + url_ok = cls.match(url) is not None deps_ok = all(cls.REQUIRES.values()) if url_ok and not deps_ok: missing = [k for k, v in cls.REQUIRES.items() if v is None] diff --git a/dvc/remote/gs.py b/dvc/remote/gs.py index 67426aa7e..d44eaa343 100644 --- a/dvc/remote/gs.py +++ b/dvc/remote/gs.py @@ -33,6 +33,13 @@ class RemoteGS(RemoteBase): self.url = config.get(Config.SECTION_REMOTE_URL, storagepath) self.projectname = config.get(Config.SECTION_GCP_PROJECTNAME, None) + @staticmethod + def compat_config(config): + ret = config.copy() + url = 'gs://' + ret.pop(Config.SECTION_AWS_STORAGEPATH, '').lstrip('/') + ret[Config.SECTION_REMOTE_URL] = url + return ret + @property def bucket(self): return urlparse(self.url).netloc diff --git a/dvc/remote/local.py b/dvc/remote/local.py index 81bb0cac1..a6fbe3fd6 100644 --- a/dvc/remote/local.py +++ b/dvc/remote/local.py @@ -50,6 +50,13 @@ class RemoteLOCAL(RemoteBase): if self.cache_dir is not None and not os.path.exists(self.cache_dir): os.mkdir(self.cache_dir) + @staticmethod + def compat_config(config): + ret = config.copy() + url = ret.pop(Config.SECTION_AWS_STORAGEPATH, '') + ret[Config.SECTION_REMOTE_URL] = url + return ret + @property def url(self): return self.cache_dir diff --git a/dvc/remote/s3.py b/dvc/remote/s3.py index d4e44cc61..8728a6981 100644 --- a/dvc/remote/s3.py +++ b/dvc/remote/s3.py @@ -64,6 +64,13 @@ class RemoteS3(RemoteBase): self.aws_access_key_id = creds.get('aws_access_key_id', None) self.aws_secret_access_key = creds.get('aws_secret_access_key', None) + @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 + @property def bucket(self): return urlparse(self.url).netloc diff --git a/tests/test_data_cloud.py b/tests/test_data_cloud.py index f44051fed..32b07dd48 100644 --- a/tests/test_data_cloud.py +++ b/tests/test_data_cloud.py @@ -160,8 +160,8 @@ class TestDataCloud(TestDvc): def test(self): config = TEST_CONFIG - clist = [('s3://', RemoteS3), - ('gs://', RemoteGS), + clist = [('s3://mybucket/', RemoteS3), + ('gs://mybucket/', RemoteGS), ('ssh://user@localhost:/', RemoteSSH), (TestDvc.mkdtemp(), RemoteLOCAL)]