From b4143b19dd78472c6a8f3bfd872084cb44e34164 Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Sun, 12 May 2019 17:29:38 +0300 Subject: [PATCH] remote: unify class names Signed-off-by: Ruslan Kuprieiev --- dvc/data_cloud.py | 10 +++++----- dvc/output/base.py | 4 ++-- dvc/remote/__init__.py | 4 ++-- dvc/remote/azure.py | 6 +++--- dvc/remote/base.py | 2 +- dvc/remote/gs.py | 4 ++-- dvc/remote/hdfs.py | 4 ++-- dvc/remote/http.py | 4 ++-- dvc/remote/local/__init__.py | 4 ++-- dvc/remote/oss.py | 4 ++-- dvc/remote/s3.py | 4 ++-- dvc/remote/ssh/__init__.py | 4 ++-- dvc/stage.py | 4 ++-- tests/func/test_data_cloud.py | 12 ++++++------ tests/func/test_remote.py | 6 +++--- tests/unit/remote/test_azure.py | 8 ++++---- tests/unit/remote/test_base.py | 12 ++++++------ 17 files changed, 48 insertions(+), 48 deletions(-) diff --git a/dvc/data_cloud.py b/dvc/data_cloud.py index 73649f06b..490a60bfa 100644 --- a/dvc/data_cloud.py +++ b/dvc/data_cloud.py @@ -8,7 +8,7 @@ from dvc.config import Config, ConfigError from dvc.remote import Remote from dvc.remote.s3 import RemoteS3 from dvc.remote.gs import RemoteGS -from dvc.remote.azure import RemoteAzure +from dvc.remote.azure import RemoteAZURE from dvc.remote.oss import RemoteOSS from dvc.remote.ssh import RemoteSSH from dvc.remote.hdfs import RemoteHDFS @@ -34,7 +34,7 @@ class DataCloud(object): CLOUD_MAP = { "aws": RemoteS3, "gcp": RemoteGS, - "azure": RemoteAzure, + "azure": RemoteAZURE, "oss": RemoteOSS, "ssh": RemoteSSH, "hdfs": RemoteHDFS, @@ -124,7 +124,7 @@ class DataCloud(object): Args: targets (list): list of targets to push to the cloud. jobs (int): number of jobs that can be running simultaneously. - remote (dvc.remote.base.RemoteBase): optional remote to push to. + remote (dvc.remote.base.RemoteBASE): optional remote to push to. By default remote from core.remote config option is used. show_checksums (bool): show checksums instead of file names in information messages. @@ -142,7 +142,7 @@ class DataCloud(object): Args: targets (list): list of targets to pull from the cloud. jobs (int): number of jobs that can be running simultaneously. - remote (dvc.remote.base.RemoteBase): optional remote to pull from. + remote (dvc.remote.base.RemoteBASE): optional remote to pull from. By default remote from core.remote config option is used. show_checksums (bool): show checksums instead of file names in information messages. @@ -160,7 +160,7 @@ class DataCloud(object): Args: targets (list): list of targets to check status for. jobs (int): number of jobs that can be running simultaneously. - remote (dvc.remote.base.RemoteBase): optional remote to compare + remote (dvc.remote.base.RemoteBASE): optional remote to compare targets to. By default remote from core.remote config option is used. show_checksums (bool): show checksums instead of file names in diff --git a/dvc/output/base.py b/dvc/output/base.py index 9e9be29c6..784c12e99 100644 --- a/dvc/output/base.py +++ b/dvc/output/base.py @@ -8,7 +8,7 @@ from schema import Or, Optional from dvc.exceptions import DvcException from dvc.utils.compat import str -from dvc.remote.base import RemoteBase +from dvc.remote.base import RemoteBASE logger = logging.getLogger(__name__) @@ -35,7 +35,7 @@ class OutputAlreadyTrackedError(DvcException): class OutputBase(object): IS_DEPENDENCY = False - REMOTE = RemoteBase + REMOTE = RemoteBASE PARAM_PATH = "path" PARAM_CACHE = "cache" diff --git a/dvc/remote/__init__.py b/dvc/remote/__init__.py index 5dadbc03d..4eb124199 100644 --- a/dvc/remote/__init__.py +++ b/dvc/remote/__init__.py @@ -1,6 +1,6 @@ from __future__ import unicode_literals -from dvc.remote.azure import RemoteAzure +from dvc.remote.azure import RemoteAZURE from dvc.remote.gs import RemoteGS from dvc.remote.hdfs import RemoteHDFS from dvc.remote.local import RemoteLOCAL @@ -12,7 +12,7 @@ from dvc.remote.oss import RemoteOSS REMOTES = [ - RemoteAzure, + RemoteAZURE, RemoteGS, RemoteHDFS, RemoteHTTP, diff --git a/dvc/remote/azure.py b/dvc/remote/azure.py index 91031040c..df86d7540 100644 --- a/dvc/remote/azure.py +++ b/dvc/remote/azure.py @@ -18,7 +18,7 @@ from dvc.utils import tmp_fname, move from dvc.utils.compat import urlparse, makedirs from dvc.progress import progress from dvc.config import Config -from dvc.remote.base import RemoteBase +from dvc.remote.base import RemoteBASE logger = logging.getLogger(__name__) @@ -32,7 +32,7 @@ class Callback(object): progress.update_target(self.name, current, total) -class RemoteAzure(RemoteBase): +class RemoteAZURE(RemoteBASE): scheme = Schemes.AZURE REGEX = ( r"azure://((?P[^=;]*)?|(" @@ -45,7 +45,7 @@ class RemoteAzure(RemoteBase): COPY_POLL_SECONDS = 5 def __init__(self, repo, config): - super(RemoteAzure, self).__init__(repo, config) + super(RemoteAZURE, self).__init__(repo, config) self.url = config.get(Config.SECTION_REMOTE_URL, "azure://") match = re.match(self.REGEX, self.url) # backward compatibility diff --git a/dvc/remote/base.py b/dvc/remote/base.py index 0ef72972b..64f8bae6c 100644 --- a/dvc/remote/base.py +++ b/dvc/remote/base.py @@ -66,7 +66,7 @@ class RemoteMissingDepsError(DvcException): pass -class RemoteBase(object): +class RemoteBASE(object): scheme = None REGEX = None REQUIRES = {} diff --git a/dvc/remote/gs.py b/dvc/remote/gs.py index 25959993e..2e747f1dd 100644 --- a/dvc/remote/gs.py +++ b/dvc/remote/gs.py @@ -13,7 +13,7 @@ except ImportError: from dvc.utils import tmp_fname, move from dvc.utils.compat import urlparse, makedirs -from dvc.remote.base import RemoteBase +from dvc.remote.base import RemoteBASE from dvc.config import Config from dvc.progress import progress from dvc.exceptions import DvcException @@ -22,7 +22,7 @@ from dvc.exceptions import DvcException logger = logging.getLogger(__name__) -class RemoteGS(RemoteBase): +class RemoteGS(RemoteBASE): scheme = Schemes.GS REGEX = r"^gs://(?P.*)$" REQUIRES = {"google.cloud.storage": storage} diff --git a/dvc/remote/hdfs.py b/dvc/remote/hdfs.py index d40c665c0..b8a3b22cc 100644 --- a/dvc/remote/hdfs.py +++ b/dvc/remote/hdfs.py @@ -10,14 +10,14 @@ from subprocess import Popen, PIPE from dvc.config import Config from dvc.scheme import Schemes from dvc.path.hdfs import PathHDFS -from dvc.remote.base import RemoteBase, RemoteCmdError +from dvc.remote.base import RemoteBASE, RemoteCmdError from dvc.utils import fix_env, tmp_fname logger = logging.getLogger(__name__) -class RemoteHDFS(RemoteBase): +class RemoteHDFS(RemoteBASE): scheme = Schemes.HDFS REGEX = r"^hdfs://((?P.*)@)?.*$" PARAM_CHECKSUM = "checksum" diff --git a/dvc/remote/http.py b/dvc/remote/http.py index d684e5bb2..6af541104 100644 --- a/dvc/remote/http.py +++ b/dvc/remote/http.py @@ -12,7 +12,7 @@ import logging from dvc.progress import progress from dvc.exceptions import DvcException from dvc.config import Config -from dvc.remote.base import RemoteBase +from dvc.remote.base import RemoteBASE from dvc.utils import move @@ -32,7 +32,7 @@ class ProgressBarCallback(object): progress.update_target(self.name, self.current, self.total) -class RemoteHTTP(RemoteBase): +class RemoteHTTP(RemoteBASE): scheme = Schemes.HTTP REGEX = r"^http://.*$" REQUEST_TIMEOUT = 10 diff --git a/dvc/remote/local/__init__.py b/dvc/remote/local/__init__.py index 24d581ad9..4638f723a 100644 --- a/dvc/remote/local/__init__.py +++ b/dvc/remote/local/__init__.py @@ -18,7 +18,7 @@ import logging from dvc.system import System from dvc.remote.base import ( - RemoteBase, + RemoteBASE, STATUS_MAP, STATUS_NEW, STATUS_DELETED, @@ -44,7 +44,7 @@ from dvc.utils.fs import get_mtime_and_size, get_inode logger = logging.getLogger(__name__) -class RemoteLOCAL(RemoteBase): +class RemoteLOCAL(RemoteBASE): scheme = Schemes.LOCAL REGEX = r"^(?P.*)$" PARAM_CHECKSUM = "md5" diff --git a/dvc/remote/oss.py b/dvc/remote/oss.py index 3c851cd93..56879501d 100644 --- a/dvc/remote/oss.py +++ b/dvc/remote/oss.py @@ -16,14 +16,14 @@ from dvc.utils import tmp_fname, move from dvc.utils.compat import urlparse, makedirs from dvc.progress import progress from dvc.config import Config -from dvc.remote.base import RemoteBase +from dvc.remote.base import RemoteBASE from dvc.remote.azure import Callback logger = logging.getLogger(__name__) -class RemoteOSS(RemoteBase): +class RemoteOSS(RemoteBASE): """ oss2 document: https://www.alibabacloud.com/help/doc-detail/32026.htm diff --git a/dvc/remote/s3.py b/dvc/remote/s3.py index e4946a245..99ff523d2 100644 --- a/dvc/remote/s3.py +++ b/dvc/remote/s3.py @@ -16,7 +16,7 @@ from dvc.utils import tmp_fname, move from dvc.utils.compat import urlparse, makedirs from dvc.progress import progress from dvc.config import Config -from dvc.remote.base import RemoteBase +from dvc.remote.base import RemoteBASE from dvc.exceptions import DvcException, ETagMismatchError logger = logging.getLogger(__name__) @@ -35,7 +35,7 @@ class Callback(object): progress.update_target(self.name, self.current, self.total) -class RemoteS3(RemoteBase): +class RemoteS3(RemoteBASE): scheme = Schemes.S3 REGEX = r"^s3://(?P.*)$" REQUIRES = {"boto3": boto3} diff --git a/dvc/remote/ssh/__init__.py b/dvc/remote/ssh/__init__.py index 291f8a088..836d5644e 100644 --- a/dvc/remote/ssh/__init__.py +++ b/dvc/remote/ssh/__init__.py @@ -16,13 +16,13 @@ import dvc.prompt as prompt from dvc.remote.ssh.connection import SSHConnection from dvc.config import Config from dvc.utils.compat import urlparse -from dvc.remote.base import RemoteBase +from dvc.remote.base import RemoteBASE logger = logging.getLogger(__name__) -class RemoteSSH(RemoteBase): +class RemoteSSH(RemoteBASE): scheme = Schemes.SSH # NOTE: we support both URL-like (ssh://[user@]host.xz[:port]/path) and diff --git a/dvc/stage.py b/dvc/stage.py index 3e0e81e00..a5b018230 100644 --- a/dvc/stage.py +++ b/dvc/stage.py @@ -619,14 +619,14 @@ class Stage(object): return stage def dumpd(self): - from dvc.remote.base import RemoteBase + from dvc.remote.base import RemoteBASE return { key: value for key, value in { Stage.PARAM_MD5: self.md5, Stage.PARAM_CMD: self.cmd, - Stage.PARAM_WDIR: RemoteBase.to_posixpath( + Stage.PARAM_WDIR: RemoteBASE.to_posixpath( os.path.relpath(self.wdir, os.path.dirname(self.path)) ), Stage.PARAM_LOCKED: self.locked, diff --git a/tests/func/test_data_cloud.py b/tests/func/test_data_cloud.py index 66a07ad44..45067b0c1 100644 --- a/tests/func/test_data_cloud.py +++ b/tests/func/test_data_cloud.py @@ -19,7 +19,7 @@ from dvc.data_cloud import ( DataCloud, RemoteS3, RemoteGS, - RemoteAzure, + RemoteAZURE, RemoteOSS, RemoteLOCAL, RemoteSSH, @@ -244,7 +244,7 @@ class TestDataCloud(TestDvc): ("gs://mybucket/", RemoteGS), ("ssh://user@localhost:/", RemoteSSH), ("http://localhost:8000/", RemoteHTTP), - ("azure://ContainerName=mybucket;conn_string;", RemoteAzure), + ("azure://ContainerName=mybucket;conn_string;", RemoteAZURE), ("oss://mybucket/", RemoteOSS), (TestDvc.mkdtemp(), RemoteLOCAL), ] @@ -403,7 +403,7 @@ class TestRemoteGS(TestDataCloudBase): return RemoteGS -class TestRemoteAzureCompat(TestDataCloudBase): +class TestRemoteAZURECompat(TestDataCloudBase): def _should_test(self): return _should_test_azure() @@ -411,10 +411,10 @@ class TestRemoteAzureCompat(TestDataCloudBase): return get_azure_url_compat() def _get_cloud_class(self): - return RemoteAzure + return RemoteAZURE -class TestRemoteAzure(TestRemoteAzureCompat): +class TestRemoteAZURE(TestRemoteAZURECompat): def _get_url(self): return get_azure_url() @@ -673,7 +673,7 @@ class TestRemoteGSCLI(TestDataCloudCLIBase): self._test_cloud(TEST_REMOTE) -class TestRemoteAzureCLI(TestDataCloudCLIBase): +class TestRemoteAZURECLI(TestDataCloudCLIBase): def _should_test(self): return _should_test_azure() diff --git a/tests/func/test_remote.py b/tests/func/test_remote.py index 3af5e642f..9c2ca42ad 100644 --- a/tests/func/test_remote.py +++ b/tests/func/test_remote.py @@ -1,7 +1,7 @@ import os import configobj from dvc.path.local import PathLOCAL -from dvc.remote.base import RemoteBase +from dvc.remote.base import RemoteBASE from mock import patch from dvc.main import main @@ -202,7 +202,7 @@ def test_dir_checksum_should_be_key_order_agnostic(dvc): path_info = PathLOCAL(path=data_dir) with dvc.state: with patch.object( - RemoteBase, + RemoteBASE, "_collect_dir", return_value=[ {"relpath": "1", "md5": "1"}, @@ -212,7 +212,7 @@ def test_dir_checksum_should_be_key_order_agnostic(dvc): checksum1 = dvc.cache.local.get_dir_checksum(path_info) with patch.object( - RemoteBase, + RemoteBASE, "_collect_dir", return_value=[ {"md5": "1", "relpath": "1"}, diff --git a/tests/unit/remote/test_azure.py b/tests/unit/remote/test_azure.py index 676651f61..4ddb57ae9 100644 --- a/tests/unit/remote/test_azure.py +++ b/tests/unit/remote/test_azure.py @@ -1,9 +1,9 @@ from unittest import TestCase -from dvc.remote.azure import RemoteAzure +from dvc.remote.azure import RemoteAZURE -class TestRemoteAzure(TestCase): +class TestRemoteAZURE(TestCase): container_name = "container-name" connection_string = ( "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;" @@ -20,7 +20,7 @@ class TestRemoteAzure(TestCase): connection_string=self.connection_string, ) config = {"url": url} - remote = RemoteAzure(None, config) + remote = RemoteAZURE(None, config) self.assertEqual(remote.url, url) self.assertEqual(remote.prefix, "") self.assertEqual(remote.bucket, self.container_name) @@ -30,7 +30,7 @@ class TestRemoteAzure(TestCase): prefix = "some/prefix" url = "azure://{}/{}".format(self.container_name, prefix) config = {"url": url, "connection_string": self.connection_string} - remote = RemoteAzure(None, config) + remote = RemoteAZURE(None, config) self.assertEqual(remote.url, url) self.assertEqual(remote.prefix, prefix) self.assertEqual(remote.bucket, self.container_name) diff --git a/tests/unit/remote/test_base.py b/tests/unit/remote/test_base.py index 751198fc2..39ed3e5ee 100644 --- a/tests/unit/remote/test_base.py +++ b/tests/unit/remote/test_base.py @@ -2,14 +2,14 @@ import mock from unittest import TestCase from dvc.path.base import PathBASE -from dvc.remote.base import RemoteBase, RemoteCmdError, RemoteMissingDepsError +from dvc.remote.base import RemoteBASE, RemoteCmdError, RemoteMissingDepsError -class TestRemoteBase(object): - REMOTE_CLS = RemoteBase +class TestRemoteBASE(object): + REMOTE_CLS = RemoteBASE -class TestMissingDeps(TestCase, TestRemoteBase): +class TestMissingDeps(TestCase, TestRemoteBASE): def test(self): REQUIRES = {"foo": None, "bar": None, "mock": mock} with mock.patch.object(self.REMOTE_CLS, "REQUIRES", REQUIRES): @@ -17,7 +17,7 @@ class TestMissingDeps(TestCase, TestRemoteBase): self.REMOTE_CLS(None, {}) -class TestCmdError(TestCase, TestRemoteBase): +class TestCmdError(TestCase, TestRemoteBASE): def test(self): repo = None config = {} @@ -41,7 +41,7 @@ class TestCacheExists(TestCase): "url": "base://example/prefix", "connection_string": "1234567", } - remote = RemoteBase(None, config) + remote = RemoteBASE(None, config) remote.PARAM_CHECKSUM = "checksum" remote.path_info = PathBASE(None, None)