Skip to content

Commit

Permalink
dvc: rename *RemoteTree to *Tree
Browse files Browse the repository at this point in the history
  • Loading branch information
efiop committed Jul 19, 2020
1 parent dde7561 commit eb619a8
Show file tree
Hide file tree
Showing 60 changed files with 247 additions and 273 deletions.
4 changes: 2 additions & 2 deletions dvc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class Config(dict):
def __init__(
self, dvc_dir=None, validate=True, tree=None,
): # pylint: disable=super-init-not-called
from dvc.tree.local import LocalRemoteTree
from dvc.tree.local import LocalTree

self.dvc_dir = dvc_dir

Expand All @@ -251,7 +251,7 @@ def __init__(
else:
self.dvc_dir = os.path.abspath(os.path.realpath(dvc_dir))

self.wtree = LocalRemoteTree(None, {"url": self.dvc_dir})
self.wtree = LocalTree(None, {"url": self.dvc_dir})
self.tree = tree or self.wtree

self.load(validate=validate)
Expand Down
4 changes: 2 additions & 2 deletions dvc/dependency/azure.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from dvc.dependency.base import BaseDependency
from dvc.output.base import BaseOutput

from ..tree.azure import AzureRemoteTree
from ..tree.azure import AzureTree


class AzureDependency(BaseDependency, BaseOutput):
TREE_CLS = AzureRemoteTree
TREE_CLS = AzureTree
4 changes: 2 additions & 2 deletions dvc/dependency/http.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from dvc.dependency.base import BaseDependency
from dvc.output.base import BaseOutput

from ..tree.http import HTTPRemoteTree
from ..tree.http import HTTPTree


class HTTPDependency(BaseDependency, BaseOutput):
TREE_CLS = HTTPRemoteTree
TREE_CLS = HTTPTree
4 changes: 2 additions & 2 deletions dvc/dependency/https.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from ..tree.https import HTTPSRemoteTree
from ..tree.https import HTTPSTree
from .http import HTTPDependency


class HTTPSDependency(HTTPDependency):
TREE_CLS = HTTPSRemoteTree
TREE_CLS = HTTPSTree
4 changes: 2 additions & 2 deletions dvc/external_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from dvc.repo import Repo
from dvc.repo.tree import RepoTree
from dvc.scm.git import Git
from dvc.tree.local import LocalRemoteTree
from dvc.tree.local import LocalTree
from dvc.utils.fs import remove

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -102,7 +102,7 @@ def repo_tree(self):
return RepoTree(self, fetch=True)

def get_rev(self):
if isinstance(self.tree, LocalRemoteTree):
if isinstance(self.tree, LocalTree):
return self.scm.get_rev()
return self.tree.rev

Expand Down
12 changes: 6 additions & 6 deletions dvc/output/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
from dvc.scheme import Schemes

from ..tree import get_cloud_tree
from ..tree.hdfs import HDFSRemoteTree
from ..tree.local import LocalRemoteTree
from ..tree.s3 import S3RemoteTree
from ..tree.hdfs import HDFSTree
from ..tree.local import LocalTree
from ..tree.s3 import S3Tree

OUTS = [
HDFSOutput,
Expand Down Expand Up @@ -48,9 +48,9 @@
# so when a few types of outputs share the same name, we only need
# specify it once.
CHECKSUMS_SCHEMA = {
LocalRemoteTree.PARAM_CHECKSUM: CHECKSUM_SCHEMA,
S3RemoteTree.PARAM_CHECKSUM: CHECKSUM_SCHEMA,
HDFSRemoteTree.PARAM_CHECKSUM: CHECKSUM_SCHEMA,
LocalTree.PARAM_CHECKSUM: CHECKSUM_SCHEMA,
S3Tree.PARAM_CHECKSUM: CHECKSUM_SCHEMA,
HDFSTree.PARAM_CHECKSUM: CHECKSUM_SCHEMA,
}

SCHEMA = CHECKSUMS_SCHEMA.copy()
Expand Down
4 changes: 2 additions & 2 deletions dvc/output/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
RemoteCacheRequiredError,
)

from ..tree.base import BaseRemoteTree
from ..tree.base import BaseTree

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -48,7 +48,7 @@ def __init__(self, path):
class BaseOutput:
IS_DEPENDENCY = False

TREE_CLS = BaseRemoteTree
TREE_CLS = BaseTree

PARAM_PATH = "path"
PARAM_CACHE = "cache"
Expand Down
4 changes: 2 additions & 2 deletions dvc/output/gs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from dvc.output.s3 import S3Output

from ..tree.gs import GSRemoteTree
from ..tree.gs import GSTree


class GSOutput(S3Output):
TREE_CLS = GSRemoteTree
TREE_CLS = GSTree
4 changes: 2 additions & 2 deletions dvc/output/hdfs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from dvc.output.base import BaseOutput

from ..tree.hdfs import HDFSRemoteTree
from ..tree.hdfs import HDFSTree


class HDFSOutput(BaseOutput):
TREE_CLS = HDFSRemoteTree
TREE_CLS = HDFSTree
6 changes: 3 additions & 3 deletions dvc/output/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
from dvc.utils import relpath
from dvc.utils.fs import path_isin

from ..tree.local import LocalRemoteTree
from ..tree.local import LocalTree

logger = logging.getLogger(__name__)


class LocalOutput(BaseOutput):
TREE_CLS = LocalRemoteTree
TREE_CLS = LocalTree
sep = os.sep

def __init__(self, stage, path, *args, **kwargs):
Expand All @@ -25,7 +25,7 @@ def __init__(self, stage, path, *args, **kwargs):
if (
self.is_in_repo
and self.repo
and isinstance(self.repo.tree, LocalRemoteTree)
and isinstance(self.repo.tree, LocalTree)
):
self.tree = self.repo.tree

Expand Down
4 changes: 2 additions & 2 deletions dvc/output/s3.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from dvc.output.base import BaseOutput

from ..tree.s3 import S3RemoteTree
from ..tree.s3 import S3Tree


class S3Output(BaseOutput):
TREE_CLS = S3RemoteTree
TREE_CLS = S3Tree
4 changes: 2 additions & 2 deletions dvc/output/ssh.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from dvc.output.base import BaseOutput

from ..tree.ssh import SSHRemoteTree
from ..tree.ssh import SSHTree


class SSHOutput(BaseOutput):
TREE_CLS = SSHRemoteTree
TREE_CLS = SSHTree
4 changes: 2 additions & 2 deletions dvc/remote/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
)
from dvc.remote.index import RemoteIndexNoop

from ..tree.local import LocalRemoteTree
from ..tree.local import LocalTree

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -52,7 +52,7 @@ class LocalRemote(Remote):

class LocalCache(CloudCache):
DEFAULT_CACHE_TYPES = ["reflink", "copy"]
CACHE_MODE = LocalRemoteTree.CACHE_MODE
CACHE_MODE = LocalTree.CACHE_MODE

def __init__(self, tree):
super().__init__(tree)
Expand Down
4 changes: 2 additions & 2 deletions dvc/repo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def __init__(self, root_dir=None, scm=None, rev=None):
from dvc.repo.metrics import Metrics
from dvc.repo.plots import Plots
from dvc.repo.params import Params
from dvc.tree.local import LocalRemoteTree
from dvc.tree.local import LocalTree
from dvc.utils.fs import makedirs
from dvc.stage.cache import StageCache

Expand All @@ -91,7 +91,7 @@ def __init__(self, root_dir=None, scm=None, rev=None):
else:
root_dir = self.find_root(root_dir)
self.root_dir = os.path.abspath(os.path.realpath(root_dir))
self.tree = LocalRemoteTree(
self.tree = LocalTree(
self,
{"url": self.root_dir},
use_dvcignore=True,
Expand Down
6 changes: 2 additions & 4 deletions dvc/repo/brancher.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from funcy import group_by

from dvc.tree.local import LocalRemoteTree
from dvc.tree.local import LocalTree


def brancher( # noqa: E302
Expand Down Expand Up @@ -29,9 +29,7 @@ def brancher( # noqa: E302

scm = self.scm

self.tree = LocalRemoteTree(
self, {"url": self.root_dir}, use_dvcignore=True
)
self.tree = LocalTree(self, {"url": self.root_dir}, use_dvcignore=True)
yield "workspace"

if revs and "workspace" in revs:
Expand Down
4 changes: 2 additions & 2 deletions dvc/repo/diff.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os

from dvc.repo import locked
from dvc.tree.local import LocalRemoteTree
from dvc.tree.local import LocalTree


@locked
Expand Down Expand Up @@ -33,7 +33,7 @@ def _to_path(output):
else os.path.join(str(output), "")
)

on_working_tree = isinstance(self.tree, LocalRemoteTree)
on_working_tree = isinstance(self.tree, LocalTree)

def _to_checksum(output):
if on_working_tree:
Expand Down
6 changes: 3 additions & 3 deletions dvc/repo/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
from dvc.exceptions import OutputNotFoundError
from dvc.path_info import PathInfo
from dvc.remote.base import RemoteActionNotImplemented
from dvc.tree.base import BaseRemoteTree
from dvc.tree.base import BaseTree
from dvc.utils import file_md5
from dvc.utils.fs import copy_fobj_to_file, makedirs

logger = logging.getLogger(__name__)


class DvcTree(BaseRemoteTree): # pylint:disable=abstract-method
class DvcTree(BaseTree): # pylint:disable=abstract-method
"""DVC repo tree.
Args:
Expand Down Expand Up @@ -237,7 +237,7 @@ def get_file_hash(self, path_info):
return out.checksum


class RepoTree(BaseRemoteTree): # pylint:disable=abstract-method
class RepoTree(BaseTree): # pylint:disable=abstract-method
"""DVC + git-tracked files tree.
Args:
Expand Down
8 changes: 4 additions & 4 deletions dvc/stage/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from dvc.utils.fs import path_isin

from ..dependency import ParamsDependency
from ..tree.local import LocalRemoteTree
from ..tree.s3 import S3RemoteTree
from ..tree.local import LocalTree
from ..tree.s3 import S3Tree
from ..utils import dict_md5, format_link, relpath
from .exceptions import (
MissingDataSource,
Expand Down Expand Up @@ -133,8 +133,8 @@ def stage_dump_eq(stage_cls, old_d, new_d):
new_d.pop(stage_cls.PARAM_MD5, None)
outs = old_d.get(stage_cls.PARAM_OUTS, [])
for out in outs:
out.pop(LocalRemoteTree.PARAM_CHECKSUM, None)
out.pop(S3RemoteTree.PARAM_CHECKSUM, None)
out.pop(LocalTree.PARAM_CHECKSUM, None)
out.pop(S3Tree.PARAM_CHECKSUM, None)

# outs and deps are lists of dicts. To check equality, we need to make
# them independent of the order, so, we convert them to dicts.
Expand Down
6 changes: 3 additions & 3 deletions dvc/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ class State: # pylint: disable=too-many-instance-attributes
MAX_UINT = 2 ** 64 - 2

def __init__(self, local_cache):
from dvc.tree.local import LocalRemoteTree
from dvc.tree.local import LocalTree

repo = local_cache.repo
self.repo = repo
self.root_dir = repo.root_dir
self.tree = LocalRemoteTree(None, {"url": self.root_dir})
self.tree = LocalTree(None, {"url": self.root_dir})

state_config = repo.config.get("state", {})
self.row_limit = state_config.get("row_limit", self.STATE_ROW_LIMIT)
Expand Down Expand Up @@ -396,7 +396,7 @@ def get(self, path_info):
assert isinstance(path_info, str) or path_info.scheme == "local"
path = os.fspath(path_info)

# NOTE: use os.path.exists instead of LocalRemoteTree.exists
# NOTE: use os.path.exists instead of LocalTree.exists
# because it uses lexists() and will return True for broken
# symlinks that we cannot stat() in get_mtime_and_size
if not os.path.exists(path):
Expand Down
42 changes: 21 additions & 21 deletions dvc/tree/__init__.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
import posixpath
from urllib.parse import urlparse

from .azure import AzureRemoteTree
from .gdrive import GDriveRemoteTree
from .gs import GSRemoteTree
from .hdfs import HDFSRemoteTree
from .http import HTTPRemoteTree
from .https import HTTPSRemoteTree
from .local import LocalRemoteTree
from .oss import OSSRemoteTree
from .s3 import S3RemoteTree
from .ssh import SSHRemoteTree
from .azure import AzureTree
from .gdrive import GDriveTree
from .gs import GSTree
from .hdfs import HDFSTree
from .http import HTTPTree
from .https import HTTPSTree
from .local import LocalTree
from .oss import OSSTree
from .s3 import S3Tree
from .ssh import SSHTree

TREES = [
AzureRemoteTree,
GDriveRemoteTree,
GSRemoteTree,
HDFSRemoteTree,
HTTPRemoteTree,
HTTPSRemoteTree,
S3RemoteTree,
SSHRemoteTree,
OSSRemoteTree,
# NOTE: LocalRemoteTree is the default
AzureTree,
GDriveTree,
GSTree,
HDFSTree,
HTTPTree,
HTTPSTree,
S3Tree,
SSHTree,
OSSTree,
# NOTE: LocalTree is the default
]


def _get_tree(remote_conf):
for tree_cls in TREES:
if tree_cls.supported(remote_conf):
return tree_cls
return LocalRemoteTree
return LocalTree


def _get_conf(repo, **kwargs):
Expand Down
4 changes: 2 additions & 2 deletions dvc/tree/azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
from dvc.progress import Tqdm
from dvc.scheme import Schemes

from .base import BaseRemoteTree
from .base import BaseTree

logger = logging.getLogger(__name__)


class AzureRemoteTree(BaseRemoteTree):
class AzureTree(BaseTree):
scheme = Schemes.AZURE
PATH_CLS = CloudURLInfo
REQUIRES = {
Expand Down
Loading

0 comments on commit eb619a8

Please sign in to comment.