mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-19 15:28:28 +01:00
remote: unify class names
Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
+5
-5
@@ -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
|
||||
|
||||
+2
-2
@@ -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"
|
||||
|
||||
@@ -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,
|
||||
|
||||
+3
-3
@@ -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<path>[^=;]*)?|("
|
||||
@@ -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
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ class RemoteMissingDepsError(DvcException):
|
||||
pass
|
||||
|
||||
|
||||
class RemoteBase(object):
|
||||
class RemoteBASE(object):
|
||||
scheme = None
|
||||
REGEX = None
|
||||
REQUIRES = {}
|
||||
|
||||
+2
-2
@@ -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<path>.*)$"
|
||||
REQUIRES = {"google.cloud.storage": storage}
|
||||
|
||||
+2
-2
@@ -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<user>.*)@)?.*$"
|
||||
PARAM_CHECKSUM = "checksum"
|
||||
|
||||
+2
-2
@@ -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
|
||||
|
||||
@@ -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<path>.*)$"
|
||||
PARAM_CHECKSUM = "md5"
|
||||
|
||||
+2
-2
@@ -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
|
||||
|
||||
+2
-2
@@ -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<path>.*)$"
|
||||
REQUIRES = {"boto3": boto3}
|
||||
|
||||
@@ -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
|
||||
|
||||
+2
-2
@@ -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,
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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"},
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user