diff --git a/dvc/api/__init__.py b/dvc/api/__init__.py index e1421a087f..442de716a1 100644 --- a/dvc/api/__init__.py +++ b/dvc/api/__init__.py @@ -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 @@ "open", "params_show", "read", - "DvcFileSystem", + "DVCFileSystem", ] diff --git a/dvc/dependency/repo.py b/dvc/dependency/repo.py index df75a8191d..33d3f337fb 100644 --- a/dvc/dependency/repo.py +++ b/dvc/dependency/repo.py @@ -152,7 +152,7 @@ def _get_used_and_obj( 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 @@ def iter_objs(): 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 diff --git a/dvc/fs/__init__.py b/dvc/fs/__init__.py index ed6b99d580..bce35cc0fb 100644 --- a/dvc/fs/__init__.py +++ b/dvc/fs/__init__.py @@ -24,13 +24,13 @@ 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": { diff --git a/dvc/fs/dvc.py b/dvc/fs/dvc.py index f2459f0d41..c3679766e8 100644 --- a/dvc/fs/dvc.py +++ b/dvc/fs/dvc.py @@ -64,7 +64,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: @@ -361,7 +361,7 @@ def _info(self, key, path, ignore_subrepos=True, check_ignored=True): return info -class DvcFileSystem(FileSystem): +class DVCFileSystem(FileSystem): protocol = "local" PARAM_CHECKSUM = "md5" @@ -371,7 +371,7 @@ def _prepare_credentials(self, **config): @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) diff --git a/dvc/repo/__init__.py b/dvc/repo/__init__.py index 55151f0925..520a575c00 100644 --- a/dvc/repo/__init__.py +++ b/dvc/repo/__init__.py @@ -187,7 +187,7 @@ def __init__( 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 @@ def datafs(self): @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 @@ def index_db_dir(self): 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: diff --git a/dvc/repo/collect.py b/dvc/repo/collect.py index a6000307ba..9974852e20 100644 --- a/dvc/repo/collect.py +++ b/dvc/repo/collect.py @@ -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 = [] diff --git a/dvc/repo/diff.py b/dvc/repo/diff.py index 293e26f6d4..f125d7a7ac 100644 --- a/dvc/repo/diff.py +++ b/dvc/repo/diff.py @@ -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] diff --git a/dvc/repo/ls.py b/dvc/repo/ls.py index ad1a9bb5c3..1b989095f9 100644 --- a/dvc/repo/ls.py +++ b/dvc/repo/ls.py @@ -4,7 +4,7 @@ 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: diff --git a/dvc/repo/metrics/show.py b/dvc/repo/metrics/show.py index 07f853eb33..bb209b0c05 100644 --- a/dvc/repo/metrics/show.py +++ b/dvc/repo/metrics/show.py @@ -4,7 +4,7 @@ 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(): diff --git a/dvc/repo/plots/__init__.py b/dvc/repo/plots/__init__.py index 155061474c..67b2684da2 100644 --- a/dvc/repo/plots/__init__.py +++ b/dvc/repo/plots/__init__.py @@ -152,9 +152,9 @@ def _collect_data_sources( 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( diff --git a/dvc/testing/test_api.py b/dvc/testing/test_api.py index f482d26e2a..b45e802ce0 100644 --- a/dvc/testing/test_api.py +++ b/dvc/testing/test_api.py @@ -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 @@ def test_filesystem( 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" diff --git a/setup.cfg b/setup.cfg index 4400795a94..b4bc065938 100644 --- a/setup.cfg +++ b/setup.cfg @@ -146,7 +146,7 @@ exclude = console_scripts = dvc = dvc.cli:main fsspec.specs = - dvc = dvc.api:DvcFileSystem + dvc = dvc.api:DVCFileSystem [flake8] ignore= diff --git a/tests/unit/fs/test_data.py b/tests/unit/fs/test_data.py index 6e3df4f09e..6bf64739d0 100644 --- a/tests/unit/fs/test_data.py +++ b/tests/unit/fs/test_data.py @@ -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"): diff --git a/tests/unit/fs/test_dvc.py b/tests/unit/fs/test_dvc.py index 8d2e14d5e3..7210076b60 100644 --- a/tests/unit/fs/test_dvc.py +++ b/tests/unit/fs/test_dvc.py @@ -5,7 +5,7 @@ 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 f(*args, **kwargs): ) 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 dvc_structure(suffix): 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 ): diff --git a/tests/unit/fs/test_dvc_info.py b/tests/unit/fs/test_dvc_info.py index dc175662e5..fc8a0a3a28 100644 --- a/tests/unit/fs/test_dvc_info.py +++ b/tests/unit/fs/test_dvc_info.py @@ -2,7 +2,7 @@ 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):