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