dvcfs: rename DvcFileSystem to DVCFileSystem (#8307)

This commit is contained in:
skshetry
2022-09-16 18:18:55 +05:45
committed by GitHub
parent 146bdbbe9b
commit 391bb29be2
15 changed files with 63 additions and 63 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
from dvc.fs.dvc import _DvcFileSystem as DvcFileSystem
from dvc.fs.dvc import _DVCFileSystem as DVCFileSystem
from .data import open # pylint: disable=redefined-builtin
from .data import get_url, read
@@ -11,5 +11,5 @@ __all__ = [
"open",
"params_show",
"read",
"DvcFileSystem",
"DVCFileSystem",
]
+2 -2
View File
@@ -152,7 +152,7 @@ class RepoDependency(Dependency):
def _check_circular_import(self, odb, obj_ids):
from dvc.exceptions import CircularImportError
from dvc.fs.dvc import DvcFileSystem
from dvc.fs.dvc import DVCFileSystem
from dvc_data.hashfile.db.reference import ReferenceHashFileDB
from dvc_data.hashfile.tree import Tree
@@ -169,7 +169,7 @@ class RepoDependency(Dependency):
checked_urls = set()
for obj in iter_objs():
if not isinstance(obj.fs, DvcFileSystem):
if not isinstance(obj.fs, DVCFileSystem):
continue
if (
obj.fs.repo_url in checked_urls
+2 -2
View File
@@ -24,13 +24,13 @@ from dvc_objects.fs.errors import ( # noqa: F401
from dvc_objects.fs.path import Path # noqa: F401
from .data import DataFileSystem # noqa: F401
from .dvc import DvcFileSystem # noqa: F401
from .dvc import DVCFileSystem # noqa: F401
from .git import GitFileSystem # noqa: F401
known_implementations.update(
{
"dvc": {
"class": "dvc.fs.dvc.DvcFileSystem",
"class": "dvc.fs.dvc.DVCFileSystem",
"err": "dvc is supported, but requires 'dvc' to be installed",
},
"git": {
+3 -3
View File
@@ -65,7 +65,7 @@ def _get_dvc_path(dvc_fs, subkey):
return dvc_fs.path.join(*subkey) if subkey else ""
class _DvcFileSystem(AbstractFileSystem): # pylint:disable=abstract-method
class _DVCFileSystem(AbstractFileSystem): # pylint:disable=abstract-method
"""DVC + git-tracked files fs.
Args:
@@ -365,7 +365,7 @@ class _DvcFileSystem(AbstractFileSystem): # pylint:disable=abstract-method
return info
class DvcFileSystem(FileSystem):
class DVCFileSystem(FileSystem):
protocol = "local"
PARAM_CHECKSUM = "md5"
@@ -375,7 +375,7 @@ class DvcFileSystem(FileSystem):
@wrap_prop(threading.Lock())
@cached_property
def fs(self):
return _DvcFileSystem(**self.fs_args)
return _DVCFileSystem(**self.fs_args)
def isdvc(self, path, **kwargs):
return self.fs.isdvc(path, **kwargs)
+5 -5
View File
@@ -187,7 +187,7 @@ class Repo:
self.config = Config(self.dvc_dir, fs=self.fs, config=config)
self._uninitialized = uninitialized
# used by DvcFileSystem to determine if it should traverse subrepos
# used by DVCFileSystem to determine if it should traverse subrepos
self.subrepos = subrepos
self.cloud = DataCloud(self)
@@ -526,9 +526,9 @@ class Repo:
@cached_property
def dvcfs(self):
from dvc.fs.dvc import DvcFileSystem
from dvc.fs.dvc import DVCFileSystem
return DvcFileSystem(
return DVCFileSystem(
repo=self, subrepos=self.subrepos, **self._fs_conf
)
@@ -540,13 +540,13 @@ class Repo:
def open_by_relpath(self, path, remote=None, mode="r", encoding=None):
"""Opens a specified resource as a file descriptor"""
from dvc.fs.data import DataFileSystem
from dvc.fs.dvc import DvcFileSystem
from dvc.fs.dvc import DVCFileSystem
if os.path.isabs(path):
fs = DataFileSystem(index=self.index.data["local"])
fs_path = path
else:
fs = DvcFileSystem(repo=self, subrepos=True)
fs = DVCFileSystem(repo=self, subrepos=True)
fs_path = fs.from_os_path(path)
try:
+2 -2
View File
@@ -30,9 +30,9 @@ def _collect_paths(
recursive: bool = False,
rev: str = None,
) -> StrPaths:
from dvc.fs.dvc import DvcFileSystem
from dvc.fs.dvc import DVCFileSystem
fs = DvcFileSystem(repo=repo)
fs = DVCFileSystem(repo=repo)
fs_paths = [fs.from_os_path(target) for target in targets]
target_paths: StrPaths = []
+2 -2
View File
@@ -23,9 +23,9 @@ def diff(self, a_rev="HEAD", b_rev=None, targets=None):
if self.scm.no_commits:
return {}
from dvc.fs.dvc import DvcFileSystem
from dvc.fs.dvc import DVCFileSystem
dvcfs = DvcFileSystem(repo=self)
dvcfs = DVCFileSystem(repo=self)
targets = ensure_list(targets)
targets = [dvcfs.from_os_path(target) for target in targets]
+2 -2
View File
@@ -4,7 +4,7 @@ from typing import TYPE_CHECKING, Optional
from dvc.exceptions import PathMissingError
if TYPE_CHECKING:
from dvc.fs.dvc import DvcFileSystem
from dvc.fs.dvc import DVCFileSystem
from . import Repo
@@ -55,7 +55,7 @@ def ls(
def _ls(
repo: "Repo", path: str, recursive: bool = None, dvc_only: bool = False
):
fs: "DvcFileSystem" = repo.dvcfs
fs: "DVCFileSystem" = repo.dvcfs
fs_path = fs.from_os_path(path)
try:
+2 -2
View File
@@ -4,7 +4,7 @@ from typing import List
from scmrepo.exceptions import SCMError
from dvc.fs.dvc import DvcFileSystem
from dvc.fs.dvc import DVCFileSystem
from dvc.output import Output
from dvc.repo import locked
from dvc.repo.collect import StrPaths, collect
@@ -77,7 +77,7 @@ def _read_metric(path, fs, rev, **kwargs):
def _read_metrics(repo, metrics, rev, onerror=None):
fs = DvcFileSystem(repo=repo)
fs = DVCFileSystem(repo=repo)
relpath = ""
if repo.root_dir != repo.fs.path.getcwd():
+4 -4
View File
@@ -152,9 +152,9 @@ class Plots:
props: Optional[Dict] = None,
onerror: Optional[Callable] = None,
):
from dvc.fs.dvc import DvcFileSystem
from dvc.fs.dvc import DVCFileSystem
fs = DvcFileSystem(repo=self.repo)
fs = DVCFileSystem(repo=self.repo)
props = props or {}
@@ -472,9 +472,9 @@ def _collect_definitions(
result: Dict = defaultdict(dict)
props = props or {}
from dvc.fs.dvc import DvcFileSystem
from dvc.fs.dvc import DVCFileSystem
fs = DvcFileSystem(repo=repo)
fs = DVCFileSystem(repo=repo)
if not config_files:
dpath.util.merge(
+2 -2
View File
@@ -1,7 +1,7 @@
import pytest
from dvc import api
from dvc.api import DvcFileSystem
from dvc.api import DVCFileSystem
from dvc.utils.fs import remove
@@ -59,7 +59,7 @@ class TestAPI:
path=tmp_dir, posixpath=tmp_dir.as_posix()
)
fs = DvcFileSystem(**fs_kwargs)
fs = DVCFileSystem(**fs_kwargs)
assert fs.ls("/", detail=False) == M.unordered(
"/.gitignore", "/scripts", "/data"
+1 -1
View File
@@ -146,7 +146,7 @@ exclude =
console_scripts =
dvc = dvc.cli:main
fsspec.specs =
dvc = dvc.api:DvcFileSystem
dvc = dvc.api:DVCFileSystem
[flake8]
ignore=
+2 -2
View File
@@ -50,7 +50,7 @@ def test_open_dirty_hash(tmp_dir, dvc):
fs = DataFileSystem(index=dvc.index.data["repo"])
with fs.open("file", "r") as fobj:
# NOTE: Unlike DvcFileSystem, DataFileSystem should not
# NOTE: Unlike DVCFileSystem, DataFileSystem should not
# be affected by a dirty workspace.
assert fobj.read() == "file"
@@ -71,7 +71,7 @@ def test_open_dirty_no_hash(tmp_dir, dvc):
(tmp_dir / "file.dvc").write_text("outs:\n- path: file\n")
fs = DataFileSystem(index=dvc.index.data["repo"])
# NOTE: Unlike DvcFileSystem, DataFileSystem should not
# NOTE: Unlike DVCFileSystem, DataFileSystem should not
# be affected by a dirty workspace.
with pytest.raises(FileNotFoundError):
with fs.open("file", "r"):
+30 -30
View File
@@ -5,7 +5,7 @@ from unittest import mock
import pytest
from dvc.fs.dvc import DvcFileSystem
from dvc.fs.dvc import DVCFileSystem
from dvc.testing.tmp_dir import make_subrepo
from dvc_data.hashfile.build import build
from dvc_data.hashfile.hash_info import HashInfo
@@ -16,7 +16,7 @@ def test_exists(tmp_dir, dvc):
dvc.add("foo")
(tmp_dir / "foo").unlink()
fs = DvcFileSystem(repo=dvc)
fs = DVCFileSystem(repo=dvc)
assert fs.exists("foo")
@@ -25,7 +25,7 @@ def test_open(tmp_dir, dvc):
dvc.add("foo")
(tmp_dir / "foo").unlink()
fs = DvcFileSystem(repo=dvc)
fs = DVCFileSystem(repo=dvc)
with fs.open("foo", "r") as fobj:
assert fobj.read() == "foo"
@@ -34,7 +34,7 @@ def test_open_dirty_hash(tmp_dir, dvc):
tmp_dir.dvc_gen("file", "file")
(tmp_dir / "file").write_text("something")
fs = DvcFileSystem(repo=dvc)
fs = DVCFileSystem(repo=dvc)
with fs.open("file", "r") as fobj:
assert fobj.read() == "something"
@@ -43,7 +43,7 @@ def test_open_dirty_no_hash(tmp_dir, dvc):
tmp_dir.gen("file", "file")
(tmp_dir / "file.dvc").write_text("outs:\n- path: file\n")
fs = DvcFileSystem(repo=dvc)
fs = DVCFileSystem(repo=dvc)
with fs.open("file", "r") as fobj:
assert fobj.read() == "file"
@@ -63,7 +63,7 @@ def test_open_in_history(tmp_dir, scm, dvc):
if rev == "workspace":
continue
fs = DvcFileSystem(repo=dvc)
fs = DVCFileSystem(repo=dvc)
with fs.open("foo", "r") as fobj:
assert fobj.read() == "foo"
@@ -86,7 +86,7 @@ def test_isdir_isfile(tmp_dir, dvc):
},
)
fs = DvcFileSystem(repo=dvc)
fs = DVCFileSystem(repo=dvc)
assert fs.isdir("datadir")
assert not fs.isfile("datadir")
assert not fs.isdvc("datadir")
@@ -107,7 +107,7 @@ def test_isdir_isfile(tmp_dir, dvc):
(tmp_dir / "datafile").unlink()
(tmp_dir / "subdir" / "baz").unlink()
fs = DvcFileSystem(repo=dvc)
fs = DVCFileSystem(repo=dvc)
assert fs.isdir("datadir")
assert not fs.isfile("datadir")
assert fs.isdvc("datadir")
@@ -127,7 +127,7 @@ def test_exists_isdir_isfile_dirty(tmp_dir, dvc):
{"datafile": "data", "datadir": {"foo": "foo", "bar": "bar"}}
)
fs = DvcFileSystem(repo=dvc)
fs = DVCFileSystem(repo=dvc)
shutil.rmtree(tmp_dir / "datadir")
(tmp_dir / "datafile").unlink()
@@ -162,7 +162,7 @@ def test_isdir_mixed(tmp_dir, dvc):
dvc.add(str(tmp_dir / "dir" / "foo"))
fs = DvcFileSystem(repo=dvc)
fs = DVCFileSystem(repo=dvc)
assert fs.isdir("dir")
assert not fs.isfile("dir")
@@ -192,7 +192,7 @@ def test_walk(tmp_dir, dvc, dvcfiles, extra_expected):
)
dvc.add(str(tmp_dir / "dir"), recursive=True)
tmp_dir.gen({"dir": {"foo": "foo", "bar": "bar"}})
fs = DvcFileSystem(repo=dvc)
fs = DVCFileSystem(repo=dvc)
expected = [
"dir/subdir1",
@@ -227,7 +227,7 @@ def test_walk_dirty(tmp_dir, dvc):
tmp_dir.gen({"dir": {"bar": "bar", "subdir3": {"foo3": "foo3"}}})
(tmp_dir / "dir" / "foo").unlink()
fs = DvcFileSystem(repo=dvc)
fs = DVCFileSystem(repo=dvc)
expected = [
"dir/subdir1",
"dir/subdir2",
@@ -253,7 +253,7 @@ def test_walk_dirty_cached_dir(tmp_dir, scm, dvc):
tmp_dir.dvc_gen({"data": {"foo": "foo", "bar": "bar"}}, commit="add data")
(tmp_dir / "data" / "foo").unlink()
fs = DvcFileSystem(repo=dvc)
fs = DVCFileSystem(repo=dvc)
actual = []
for root, dirs, files in fs.walk("data"):
@@ -277,7 +277,7 @@ def test_walk_mixed_dir(tmp_dir, scm, dvc):
)
tmp_dir.scm.commit("add dir")
fs = DvcFileSystem(repo=dvc)
fs = DVCFileSystem(repo=dvc)
expected = [
"dir/foo",
@@ -294,7 +294,7 @@ def test_walk_mixed_dir(tmp_dir, scm, dvc):
def test_walk_missing(tmp_dir, dvc):
fs = DvcFileSystem(repo=dvc)
fs = DVCFileSystem(repo=dvc)
for _ in fs.walk("dir"):
pass
@@ -302,7 +302,7 @@ def test_walk_missing(tmp_dir, dvc):
def test_walk_not_a_dir(tmp_dir, dvc):
tmp_dir.dvc_gen("foo", "foo")
fs = DvcFileSystem(repo=dvc)
fs = DVCFileSystem(repo=dvc)
for _ in fs.walk("foo"):
pass
@@ -312,7 +312,7 @@ def test_isdvc(tmp_dir, dvc):
tmp_dir.gen({"foo": "foo", "bar": "bar", "dir": {"baz": "baz"}})
dvc.add("foo")
dvc.add("dir")
fs = DvcFileSystem(repo=dvc)
fs = DVCFileSystem(repo=dvc)
assert fs.isdvc("foo")
assert not fs.isdvc("bar")
assert fs.isdvc("dir")
@@ -322,7 +322,7 @@ def test_isdvc(tmp_dir, dvc):
def test_subrepos(tmp_dir, scm, dvc, mocker):
tmp_dir.scm_gen(
{"dir": {"repo.txt": "file to confuse DvcFileSystem"}},
{"dir": {"repo.txt": "file to confuse DVCFileSystem"}},
commit="dir/repo.txt",
)
@@ -340,7 +340,7 @@ def test_subrepos(tmp_dir, scm, dvc, mocker):
)
dvc._reset()
fs = DvcFileSystem(repo=dvc, subrepos=True)
fs = DVCFileSystem(repo=dvc, subrepos=True)
def assert_fs_belongs_to_repo(ret_val):
method = fs.fs._get_repo
@@ -400,7 +400,7 @@ def test_subrepos(tmp_dir, scm, dvc, mocker):
)
def test_subrepo_walk(tmp_dir, scm, dvc, dvcfiles, extra_expected):
tmp_dir.scm_gen(
{"dir": {"repo.txt": "file to confuse DvcFileSystem"}},
{"dir": {"repo.txt": "file to confuse DVCFileSystem"}},
commit="dir/repo.txt",
)
@@ -420,7 +420,7 @@ def test_subrepo_walk(tmp_dir, scm, dvc, dvcfiles, extra_expected):
# using fs that does not have dvcignore
dvc._reset()
fs = DvcFileSystem(repo=dvc)
fs = DVCFileSystem(repo=dvc)
expected = [
"dir/repo",
"dir/repo.txt",
@@ -451,7 +451,7 @@ def test_subrepo_walk(tmp_dir, scm, dvc, dvcfiles, extra_expected):
def test_dvcfs_no_subrepos(tmp_dir, dvc, scm):
tmp_dir.scm_gen(
{"dir": {"repo.txt": "file to confuse DvcFileSystem"}},
{"dir": {"repo.txt": "file to confuse DVCFileSystem"}},
commit="dir/repo.txt",
)
tmp_dir.dvc_gen({"lorem": "lorem"}, commit="add foo")
@@ -464,7 +464,7 @@ def test_dvcfs_no_subrepos(tmp_dir, dvc, scm):
# using fs that does not have dvcignore
dvc._reset()
fs = DvcFileSystem(repo=dvc)
fs = DVCFileSystem(repo=dvc)
expected = [
"/.dvcignore",
"/.gitignore",
@@ -496,7 +496,7 @@ def test_dvcfs_no_subrepos(tmp_dir, dvc, scm):
def test_get_hash_cached_file(tmp_dir, dvc, mocker):
tmp_dir.dvc_gen({"foo": "foo"})
fs = DvcFileSystem(repo=dvc)
fs = DVCFileSystem(repo=dvc)
expected = "acbd18db4cc2f85cedef654fccc4a4d8"
assert fs.info("foo").get("md5") is None
_, _, obj = build(dvc.odb.local, "foo", fs, "md5")
@@ -509,7 +509,7 @@ def test_get_hash_cached_dir(tmp_dir, dvc, mocker):
tmp_dir.dvc_gen(
{"dir": {"foo": "foo", "bar": "bar", "subdir": {"data": "data"}}}
)
fs = DvcFileSystem(repo=dvc)
fs = DVCFileSystem(repo=dvc)
expected = "8761c4e9acad696bee718615e23e22db.dir"
assert fs.info("dir").get("md5") is None
_, _, obj = build(dvc.odb.local, "dir", fs, "md5")
@@ -529,7 +529,7 @@ def test_get_hash_cached_granular(tmp_dir, dvc, mocker):
tmp_dir.dvc_gen(
{"dir": {"foo": "foo", "bar": "bar", "subdir": {"data": "data"}}}
)
fs = DvcFileSystem(repo=dvc)
fs = DVCFileSystem(repo=dvc)
subdir = "dir/subdir"
assert fs.info(subdir).get("md5") is None
_, _, obj = build(dvc.odb.local, subdir, fs, "md5")
@@ -558,7 +558,7 @@ def test_get_hash_mixed_dir(tmp_dir, scm, dvc):
)
tmp_dir.scm.commit("add dir")
fs = DvcFileSystem(repo=dvc)
fs = DVCFileSystem(repo=dvc)
_, _, obj = build(dvc.odb.local, "dir", fs, "md5")
assert obj.hash_info == HashInfo(
"md5", "e1d9e8eae5374860ae025ec84cfd85c7.dir"
@@ -577,7 +577,7 @@ def test_get_hash_dirty_file(tmp_dir, dvc):
# file is modified in workspace
# hash_file(file) should return workspace hash, not DVC cached hash
fs = DvcFileSystem(repo=dvc)
fs = DVCFileSystem(repo=dvc)
assert fs.info("file").get("md5") is None
staging, _, obj = build(dvc.odb.local, "file", fs, "md5")
assert obj.hash_info == something_hash_info
@@ -599,7 +599,7 @@ def test_get_hash_dirty_dir(tmp_dir, dvc):
tmp_dir.dvc_gen({"dir": {"foo": "foo", "bar": "bar"}})
(tmp_dir / "dir" / "baz").write_text("baz")
fs = DvcFileSystem(repo=dvc)
fs = DVCFileSystem(repo=dvc)
_, meta, obj = build(dvc.odb.local, "dir", fs, "md5")
assert obj.hash_info == HashInfo(
"md5", "ba75a2162ca9c29acecb7957105a0bc2.dir"
@@ -661,7 +661,7 @@ def test_walk_nested_subrepos(tmp_dir, dvc, scm, traverse_subrepos):
expected["/subrepo1"].add("subrepo3")
actual = {}
fs = DvcFileSystem(repo=dvc)
fs = DVCFileSystem(repo=dvc)
for root, dirs, files in fs.walk(
"/", ignore_subrepos=not traverse_subrepos
):
+2 -2
View File
@@ -2,7 +2,7 @@ import os
import pytest
from dvc.fs.dvc import DvcFileSystem
from dvc.fs.dvc import DVCFileSystem
from dvc.testing.tmp_dir import make_subrepo
@@ -38,7 +38,7 @@ def dvcfs(tmp_dir, dvc, scm):
tmp_dir.scm_gen(fs_structure, commit="repo init")
tmp_dir.dvc_gen(dvc_structure, commit="use dvc")
yield DvcFileSystem(repo=dvc, subrepos=True)
yield DVCFileSystem(repo=dvc, subrepos=True)
def test_info_not_existing(dvcfs):