mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-28 07:18:29 +01:00
fs: make constructor closer to fsspec (#5911)
* fs: don't use repo for jobs/hash_jobs * fs: local: exists: use fsspec's LocalFileSystem * fs: make constructor comply with fsspec
This commit is contained in:
+16
-10
@@ -15,7 +15,7 @@ from tests.basic_env import TestDir, TestGit, TestGitSubmodule
|
||||
class TestLocalFileSystem(TestDir):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.fs = LocalFileSystem(None, {})
|
||||
self.fs = LocalFileSystem()
|
||||
|
||||
def test_open(self):
|
||||
with self.fs.open(self.FOO) as fd:
|
||||
@@ -116,7 +116,7 @@ class AssertWalkEqualMixin:
|
||||
|
||||
class TestWalkInNoSCM(AssertWalkEqualMixin, TestDir):
|
||||
def test(self):
|
||||
fs = LocalFileSystem(None, {"url": self._root_dir})
|
||||
fs = LocalFileSystem()
|
||||
self.assertWalkEqual(
|
||||
fs.walk(self._root_dir),
|
||||
[
|
||||
@@ -135,7 +135,7 @@ class TestWalkInNoSCM(AssertWalkEqualMixin, TestDir):
|
||||
)
|
||||
|
||||
def test_subdir(self):
|
||||
fs = LocalFileSystem(None, {"url": self._root_dir})
|
||||
fs = LocalFileSystem()
|
||||
self.assertWalkEqual(
|
||||
fs.walk(join("data_dir", "data_sub_dir")),
|
||||
[(join("data_dir", "data_sub_dir"), [], ["data_sub"])],
|
||||
@@ -144,7 +144,7 @@ class TestWalkInNoSCM(AssertWalkEqualMixin, TestDir):
|
||||
|
||||
class TestWalkInGit(AssertWalkEqualMixin, TestGit):
|
||||
def test_nobranch(self):
|
||||
fs = LocalFileSystem(None, {"url": self._root_dir})
|
||||
fs = LocalFileSystem(url=self._root_dir)
|
||||
walk_result = []
|
||||
for root, dirs, files in fs.walk("."):
|
||||
dirs[:] = [i for i in dirs if i != ".git"]
|
||||
@@ -244,7 +244,8 @@ def test_walk_dont_ignore_subrepos(tmp_dir, scm, dvc):
|
||||
)
|
||||
def test_fs_getsize(dvc, cloud):
|
||||
cloud.gen({"data": {"foo": "foo"}, "baz": "baz baz"})
|
||||
fs = get_cloud_fs(dvc, **cloud.config)
|
||||
cls, config = get_cloud_fs(dvc, **cloud.config)
|
||||
fs = cls(**config)
|
||||
path_info = fs.path_info
|
||||
|
||||
assert fs.getsize(path_info / "baz") == 7
|
||||
@@ -269,7 +270,8 @@ def test_fs_getsize(dvc, cloud):
|
||||
)
|
||||
def test_fs_upload_fobj(dvc, tmp_dir, cloud):
|
||||
tmp_dir.gen("foo", "foo")
|
||||
fs = get_cloud_fs(dvc, **cloud.config)
|
||||
cls, config = get_cloud_fs(dvc, **cloud.config)
|
||||
fs = cls(**config)
|
||||
|
||||
from_info = tmp_dir / "foo"
|
||||
to_info = fs.path_info / "foo"
|
||||
@@ -295,7 +297,8 @@ def test_fs_ls(dvc, cloud):
|
||||
}
|
||||
}
|
||||
)
|
||||
fs = get_cloud_fs(dvc, **cloud.config)
|
||||
cls, config = get_cloud_fs(dvc, **cloud.config)
|
||||
fs = cls(**config)
|
||||
path_info = cloud / "directory"
|
||||
|
||||
assert {os.path.basename(file_key) for file_key in fs.ls(path_info)} == {
|
||||
@@ -324,7 +327,8 @@ def test_fs_ls(dvc, cloud):
|
||||
)
|
||||
def test_fs_find_recursive(dvc, cloud):
|
||||
cloud.gen({"data": {"foo": "foo", "bar": {"baz": "baz"}, "quux": "quux"}})
|
||||
fs = get_cloud_fs(dvc, **cloud.config)
|
||||
cls, config = get_cloud_fs(dvc, **cloud.config)
|
||||
fs = cls(**config)
|
||||
path_info = fs.path_info
|
||||
|
||||
assert {
|
||||
@@ -345,7 +349,8 @@ def test_fs_find_recursive(dvc, cloud):
|
||||
)
|
||||
def test_fs_find_with_etag(dvc, cloud):
|
||||
cloud.gen({"data": {"foo": "foo", "bar": {"baz": "baz"}, "quux": "quux"}})
|
||||
fs = get_cloud_fs(dvc, **cloud.config)
|
||||
cls, config = get_cloud_fs(dvc, **cloud.config)
|
||||
fs = cls(**config)
|
||||
path_info = fs.path_info
|
||||
|
||||
for details in fs.find(path_info / "data", detail=True):
|
||||
@@ -366,7 +371,8 @@ def test_fs_find_with_etag(dvc, cloud):
|
||||
)
|
||||
def test_fs_fsspec_path_management(dvc, cloud):
|
||||
cloud.gen({"foo": "foo", "data": {"bar": "bar", "baz": {"foo": "foo"}}})
|
||||
fs = get_cloud_fs(dvc, **cloud.config)
|
||||
cls, config = get_cloud_fs(dvc, **cloud.config)
|
||||
fs = cls(**config)
|
||||
|
||||
root = cloud.parents[len(cloud.parents) - 1]
|
||||
bucket_details = fs.info(root)
|
||||
|
||||
@@ -3,7 +3,7 @@ from dvc.fs.local import LocalFileSystem
|
||||
|
||||
|
||||
def test_file_md5_crlf(tmp_dir):
|
||||
fs = LocalFileSystem(None, {})
|
||||
fs = LocalFileSystem()
|
||||
tmp_dir.gen("cr", b"a\nb\nc")
|
||||
tmp_dir.gen("crlf", b"a\r\nb\r\nc")
|
||||
assert utils.file_md5("cr", fs) == utils.file_md5("crlf", fs)
|
||||
|
||||
@@ -124,6 +124,8 @@ def gdrive(test_config, make_tmp_dir):
|
||||
tmp_dir = make_tmp_dir("gdrive", dvc=True)
|
||||
|
||||
ret = GDrive(GDrive.get_url())
|
||||
fs = GDriveFileSystem(tmp_dir.dvc, ret.config)
|
||||
fs = GDriveFileSystem(
|
||||
gdrive_credentials_tmp_dir=tmp_dir.dvc.tmp_dir, **ret.config
|
||||
)
|
||||
fs._gdrive_create_dir("root", fs.path_info.path)
|
||||
yield ret
|
||||
|
||||
@@ -20,7 +20,7 @@ def test_init_env_var(monkeypatch, dvc):
|
||||
monkeypatch.setenv("AZURE_STORAGE_CONNECTION_STRING", connection_string)
|
||||
|
||||
config = {"url": "azure://"}
|
||||
fs = AzureFileSystem(dvc, config)
|
||||
fs = AzureFileSystem(**config)
|
||||
assert fs.path_info == "azure://" + container_name
|
||||
|
||||
|
||||
@@ -28,14 +28,14 @@ def test_init(dvc):
|
||||
prefix = "some/prefix"
|
||||
url = f"azure://{container_name}/{prefix}"
|
||||
config = {"url": url, "connection_string": connection_string}
|
||||
fs = AzureFileSystem(dvc, config)
|
||||
fs = AzureFileSystem(**config)
|
||||
assert fs.path_info == url
|
||||
|
||||
|
||||
def test_info(tmp_dir, azure):
|
||||
tmp_dir.gen("foo", "foo")
|
||||
|
||||
fs = AzureFileSystem(None, azure.config)
|
||||
fs = AzureFileSystem(**azure.config)
|
||||
to_info = azure
|
||||
fs.upload(PathInfo("foo"), to_info)
|
||||
assert fs.exists(to_info)
|
||||
|
||||
@@ -16,4 +16,4 @@ def test_missing_deps(pkg, msg, mocker):
|
||||
mocker.patch.object(BaseFileSystem, "REQUIRES", requires)
|
||||
mocker.patch("dvc.utils.pkg.PKG", pkg)
|
||||
with pytest.raises(RemoteMissingDepsError, match=msg):
|
||||
BaseFileSystem(None, {})
|
||||
BaseFileSystem()
|
||||
|
||||
+16
-16
@@ -14,7 +14,7 @@ def test_exists(tmp_dir, dvc):
|
||||
dvc.add("foo")
|
||||
(tmp_dir / "foo").unlink()
|
||||
|
||||
fs = DvcFileSystem(dvc)
|
||||
fs = DvcFileSystem(repo=dvc)
|
||||
assert fs.exists("foo")
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ def test_open(tmp_dir, dvc):
|
||||
dvc.add("foo")
|
||||
(tmp_dir / "foo").unlink()
|
||||
|
||||
fs = DvcFileSystem(dvc)
|
||||
fs = DvcFileSystem(repo=dvc)
|
||||
with fs.open(PathInfo(tmp_dir) / "foo", "r") as fobj:
|
||||
assert fobj.read() == "foo"
|
||||
|
||||
@@ -32,7 +32,7 @@ def test_open_dirty_hash(tmp_dir, dvc):
|
||||
tmp_dir.dvc_gen("file", "file")
|
||||
(tmp_dir / "file").write_text("something")
|
||||
|
||||
fs = DvcFileSystem(dvc)
|
||||
fs = DvcFileSystem(repo=dvc)
|
||||
with fs.open(PathInfo(tmp_dir) / "file", "r") as fobj:
|
||||
# NOTE: Unlike RepoFileSystem, DvcFileSystem should not
|
||||
# be affected by a dirty workspace.
|
||||
@@ -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(dvc)
|
||||
fs = DvcFileSystem(repo=dvc)
|
||||
# NOTE: Unlike RepoFileSystem, DvcFileSystem should not
|
||||
# be affected by a dirty workspace.
|
||||
with pytest.raises(FileNotFoundError):
|
||||
@@ -66,7 +66,7 @@ def test_open_in_history(tmp_dir, scm, dvc):
|
||||
if rev == "workspace":
|
||||
continue
|
||||
|
||||
fs = DvcFileSystem(dvc)
|
||||
fs = DvcFileSystem(repo=dvc)
|
||||
with fs.open(PathInfo(tmp_dir) / "foo", "r") as fobj:
|
||||
assert fobj.read() == "foo"
|
||||
|
||||
@@ -74,7 +74,7 @@ def test_open_in_history(tmp_dir, scm, dvc):
|
||||
def test_isdir_isfile(tmp_dir, dvc):
|
||||
tmp_dir.gen({"datafile": "data", "datadir": {"foo": "foo", "bar": "bar"}})
|
||||
|
||||
fs = DvcFileSystem(dvc)
|
||||
fs = DvcFileSystem(repo=dvc)
|
||||
assert not fs.isdir("datadir")
|
||||
assert not fs.isfile("datadir")
|
||||
assert not fs.isdir("datafile")
|
||||
@@ -95,7 +95,7 @@ def test_isdir_mixed(tmp_dir, dvc):
|
||||
|
||||
dvc.add(str(tmp_dir / "dir" / "foo"))
|
||||
|
||||
fs = DvcFileSystem(dvc)
|
||||
fs = DvcFileSystem(repo=dvc)
|
||||
assert fs.isdir("dir")
|
||||
assert not fs.isfile("dir")
|
||||
|
||||
@@ -113,7 +113,7 @@ def test_walk(tmp_dir, dvc):
|
||||
)
|
||||
|
||||
dvc.add("dir", recursive=True)
|
||||
fs = DvcFileSystem(dvc)
|
||||
fs = DvcFileSystem(repo=dvc)
|
||||
|
||||
expected = [
|
||||
str(tmp_dir / "dir" / "subdir1"),
|
||||
@@ -147,7 +147,7 @@ def test_walk_dir(tmp_dir, dvc):
|
||||
)
|
||||
|
||||
dvc.add("dir")
|
||||
fs = DvcFileSystem(dvc)
|
||||
fs = DvcFileSystem(repo=dvc)
|
||||
|
||||
expected = [
|
||||
str(tmp_dir / "dir" / "subdir1"),
|
||||
@@ -173,7 +173,7 @@ def test_walk_onerror(tmp_dir, dvc):
|
||||
raise exc
|
||||
|
||||
tmp_dir.dvc_gen("foo", "foo")
|
||||
fs = DvcFileSystem(dvc)
|
||||
fs = DvcFileSystem(repo=dvc)
|
||||
|
||||
# path does not exist
|
||||
for _ in fs.walk("dir"):
|
||||
@@ -193,14 +193,14 @@ def test_walk_onerror(tmp_dir, dvc):
|
||||
def test_isdvc(tmp_dir, dvc):
|
||||
tmp_dir.gen({"foo": "foo", "bar": "bar"})
|
||||
dvc.add("foo")
|
||||
fs = DvcFileSystem(dvc)
|
||||
fs = DvcFileSystem(repo=dvc)
|
||||
assert fs.isdvc("foo")
|
||||
assert not fs.isdvc("bar")
|
||||
|
||||
|
||||
def test_get_hash_file(tmp_dir, dvc):
|
||||
tmp_dir.dvc_gen({"foo": "foo"})
|
||||
fs = DvcFileSystem(dvc)
|
||||
fs = DvcFileSystem(repo=dvc)
|
||||
assert (
|
||||
fs.info(PathInfo(tmp_dir) / "foo")["md5"]
|
||||
== "acbd18db4cc2f85cedef654fccc4a4d8"
|
||||
@@ -213,7 +213,7 @@ def test_get_hash_dir(tmp_dir, dvc, mocker):
|
||||
tmp_dir.dvc_gen(
|
||||
{"dir": {"foo": "foo", "bar": "bar", "subdir": {"data": "data"}}}
|
||||
)
|
||||
fs = DvcFileSystem(dvc)
|
||||
fs = DvcFileSystem(repo=dvc)
|
||||
get_file_hash_spy = mocker.spy(dvc_module.objects.stage, "get_file_hash")
|
||||
assert (
|
||||
fs.info(PathInfo(tmp_dir) / "dir")["md5"]
|
||||
@@ -226,7 +226,7 @@ def test_get_hash_granular(tmp_dir, dvc):
|
||||
tmp_dir.dvc_gen(
|
||||
{"dir": {"foo": "foo", "bar": "bar", "subdir": {"data": "data"}}}
|
||||
)
|
||||
fs = DvcFileSystem(dvc)
|
||||
fs = DvcFileSystem(repo=dvc)
|
||||
subdir = PathInfo(tmp_dir) / "dir" / "subdir"
|
||||
assert fs.info(subdir).get("md5") is None
|
||||
assert stage(dvc.odb.local, subdir, fs, "md5").hash_info == HashInfo(
|
||||
@@ -244,7 +244,7 @@ def test_get_hash_dirty_file(tmp_dir, dvc):
|
||||
tmp_dir.dvc_gen("file", "file")
|
||||
(tmp_dir / "file").write_text("something")
|
||||
|
||||
fs = DvcFileSystem(dvc)
|
||||
fs = DvcFileSystem(repo=dvc)
|
||||
expected = "8c7dd922ad47494fc02c388e12c00eac"
|
||||
assert fs.info(PathInfo(tmp_dir) / "file").get("md5") == expected
|
||||
assert stage(
|
||||
@@ -256,7 +256,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(dvc)
|
||||
fs = DvcFileSystem(repo=dvc)
|
||||
expected = "5ea40360f5b4ec688df672a4db9c17d1.dir"
|
||||
assert fs.info(PathInfo(tmp_dir) / "dir").get("md5") == expected
|
||||
assert stage(
|
||||
|
||||
+24
-24
@@ -15,7 +15,7 @@ def test_exists(tmp_dir, dvc):
|
||||
dvc.add("foo")
|
||||
(tmp_dir / "foo").unlink()
|
||||
|
||||
fs = RepoFileSystem(dvc)
|
||||
fs = RepoFileSystem(repo=dvc)
|
||||
assert fs.exists("foo")
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ def test_open(tmp_dir, dvc):
|
||||
dvc.add("foo")
|
||||
(tmp_dir / "foo").unlink()
|
||||
|
||||
fs = RepoFileSystem(dvc)
|
||||
fs = RepoFileSystem(repo=dvc)
|
||||
with fs.open(PathInfo(tmp_dir) / "foo", "r") as fobj:
|
||||
assert fobj.read() == "foo"
|
||||
|
||||
@@ -33,7 +33,7 @@ def test_open_dirty_hash(tmp_dir, dvc):
|
||||
tmp_dir.dvc_gen("file", "file")
|
||||
(tmp_dir / "file").write_text("something")
|
||||
|
||||
fs = RepoFileSystem(dvc)
|
||||
fs = RepoFileSystem(repo=dvc)
|
||||
with fs.open(PathInfo(tmp_dir) / "file", "r") as fobj:
|
||||
assert fobj.read() == "something"
|
||||
|
||||
@@ -42,7 +42,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 = RepoFileSystem(dvc)
|
||||
fs = RepoFileSystem(repo=dvc)
|
||||
with fs.open(PathInfo(tmp_dir) / "file", "r") as fobj:
|
||||
assert fobj.read() == "file"
|
||||
|
||||
@@ -62,7 +62,7 @@ def test_open_in_history(tmp_dir, scm, dvc):
|
||||
if rev == "workspace":
|
||||
continue
|
||||
|
||||
fs = RepoFileSystem(dvc)
|
||||
fs = RepoFileSystem(repo=dvc)
|
||||
with fs.open(PathInfo(tmp_dir) / "foo", "r") as fobj:
|
||||
assert fobj.read() == "foo"
|
||||
|
||||
@@ -70,7 +70,7 @@ def test_open_in_history(tmp_dir, scm, dvc):
|
||||
def test_isdir_isfile(tmp_dir, dvc):
|
||||
tmp_dir.gen({"datafile": "data", "datadir": {"foo": "foo", "bar": "bar"}})
|
||||
|
||||
fs = RepoFileSystem(dvc)
|
||||
fs = RepoFileSystem(repo=dvc)
|
||||
assert fs.isdir("datadir")
|
||||
assert not fs.isfile("datadir")
|
||||
assert not fs.isdvc("datadir")
|
||||
@@ -95,7 +95,7 @@ def test_exists_isdir_isfile_dirty(tmp_dir, dvc):
|
||||
{"datafile": "data", "datadir": {"foo": "foo", "bar": "bar"}}
|
||||
)
|
||||
|
||||
fs = RepoFileSystem(dvc)
|
||||
fs = RepoFileSystem(repo=dvc)
|
||||
shutil.rmtree(tmp_dir / "datadir")
|
||||
(tmp_dir / "datafile").unlink()
|
||||
|
||||
@@ -131,7 +131,7 @@ def test_isdir_mixed(tmp_dir, dvc):
|
||||
|
||||
dvc.add(str(tmp_dir / "dir" / "foo"))
|
||||
|
||||
fs = RepoFileSystem(dvc)
|
||||
fs = RepoFileSystem(repo=dvc)
|
||||
assert fs.isdir("dir")
|
||||
assert not fs.isfile("dir")
|
||||
|
||||
@@ -161,7 +161,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 = RepoFileSystem(dvc)
|
||||
fs = RepoFileSystem(repo=dvc)
|
||||
|
||||
expected = [
|
||||
PathInfo("dir") / "subdir1",
|
||||
@@ -196,7 +196,7 @@ def test_walk_dirty(tmp_dir, dvc):
|
||||
tmp_dir.gen({"dir": {"bar": "bar", "subdir3": {"foo3": "foo3"}}})
|
||||
(tmp_dir / "dir" / "foo").unlink()
|
||||
|
||||
fs = RepoFileSystem(dvc)
|
||||
fs = RepoFileSystem(repo=dvc)
|
||||
expected = [
|
||||
PathInfo("dir") / "subdir1",
|
||||
PathInfo("dir") / "subdir2",
|
||||
@@ -224,7 +224,7 @@ def test_walk_dirty_cached_dir(tmp_dir, scm, dvc):
|
||||
)
|
||||
(tmp_dir / "data" / "foo").unlink()
|
||||
|
||||
fs = RepoFileSystem(dvc)
|
||||
fs = RepoFileSystem(repo=dvc)
|
||||
|
||||
data = PathInfo(tmp_dir) / "data"
|
||||
|
||||
@@ -248,7 +248,7 @@ def test_walk_mixed_dir(tmp_dir, scm, dvc):
|
||||
)
|
||||
tmp_dir.scm.commit("add dir")
|
||||
|
||||
fs = RepoFileSystem(dvc)
|
||||
fs = RepoFileSystem(repo=dvc)
|
||||
|
||||
expected = [
|
||||
str(PathInfo("dir") / "foo"),
|
||||
@@ -269,7 +269,7 @@ def test_walk_onerror(tmp_dir, dvc):
|
||||
raise exc
|
||||
|
||||
tmp_dir.dvc_gen("foo", "foo")
|
||||
fs = RepoFileSystem(dvc)
|
||||
fs = RepoFileSystem(repo=dvc)
|
||||
|
||||
# path does not exist
|
||||
for _ in fs.walk("dir"):
|
||||
@@ -290,7 +290,7 @@ def test_isdvc(tmp_dir, dvc):
|
||||
tmp_dir.gen({"foo": "foo", "bar": "bar", "dir": {"baz": "baz"}})
|
||||
dvc.add("foo")
|
||||
dvc.add("dir")
|
||||
fs = RepoFileSystem(dvc)
|
||||
fs = RepoFileSystem(repo=dvc)
|
||||
assert fs.isdvc("foo")
|
||||
assert not fs.isdvc("bar")
|
||||
assert fs.isdvc("dir")
|
||||
@@ -325,7 +325,7 @@ def test_subrepos(tmp_dir, scm, dvc):
|
||||
)
|
||||
|
||||
dvc._reset()
|
||||
fs = RepoFileSystem(dvc, subrepos=True)
|
||||
fs = RepoFileSystem(repo=dvc, subrepos=True)
|
||||
|
||||
def assert_fs_belongs_to_repo(ret_val):
|
||||
method = fs._get_repo
|
||||
@@ -403,7 +403,7 @@ def test_subrepo_walk(tmp_dir, scm, dvc, dvcfiles, extra_expected):
|
||||
|
||||
# using fs that does not have dvcignore
|
||||
dvc._reset()
|
||||
fs = RepoFileSystem(dvc)
|
||||
fs = RepoFileSystem(repo=dvc)
|
||||
expected = [
|
||||
PathInfo("dir") / "repo",
|
||||
PathInfo("dir") / "repo.txt",
|
||||
@@ -448,7 +448,7 @@ def test_repo_fs_no_subrepos(tmp_dir, dvc, scm):
|
||||
|
||||
# using fs that does not have dvcignore
|
||||
dvc._reset()
|
||||
fs = RepoFileSystem(dvc)
|
||||
fs = RepoFileSystem(repo=dvc)
|
||||
expected = [
|
||||
tmp_dir / ".dvcignore",
|
||||
tmp_dir / ".gitignore",
|
||||
@@ -481,7 +481,7 @@ def test_repo_fs_no_subrepos(tmp_dir, dvc, scm):
|
||||
|
||||
def test_get_hash_cached_file(tmp_dir, dvc, mocker):
|
||||
tmp_dir.dvc_gen({"foo": "foo"})
|
||||
fs = RepoFileSystem(dvc)
|
||||
fs = RepoFileSystem(repo=dvc)
|
||||
expected = "acbd18db4cc2f85cedef654fccc4a4d8"
|
||||
assert fs.info(PathInfo(tmp_dir) / "foo").get("md5") is None
|
||||
assert stage(
|
||||
@@ -495,7 +495,7 @@ def test_get_hash_cached_dir(tmp_dir, dvc, mocker):
|
||||
tmp_dir.dvc_gen(
|
||||
{"dir": {"foo": "foo", "bar": "bar", "subdir": {"data": "data"}}}
|
||||
)
|
||||
fs = RepoFileSystem(dvc)
|
||||
fs = RepoFileSystem(repo=dvc)
|
||||
expected = "8761c4e9acad696bee718615e23e22db.dir"
|
||||
assert fs.info(PathInfo(tmp_dir) / "dir").get("md5") is None
|
||||
assert stage(
|
||||
@@ -513,7 +513,7 @@ def test_get_hash_cached_granular(tmp_dir, dvc, mocker):
|
||||
tmp_dir.dvc_gen(
|
||||
{"dir": {"foo": "foo", "bar": "bar", "subdir": {"data": "data"}}}
|
||||
)
|
||||
fs = RepoFileSystem(dvc)
|
||||
fs = RepoFileSystem(repo=dvc)
|
||||
subdir = PathInfo(tmp_dir) / "dir" / "subdir"
|
||||
assert fs.info(subdir).get("md5") is None
|
||||
assert stage(dvc.odb.local, subdir, fs, "md5").hash_info == HashInfo(
|
||||
@@ -541,7 +541,7 @@ def test_get_hash_mixed_dir(tmp_dir, scm, dvc):
|
||||
)
|
||||
tmp_dir.scm.commit("add dir")
|
||||
|
||||
fs = RepoFileSystem(dvc)
|
||||
fs = RepoFileSystem(repo=dvc)
|
||||
actual = stage(
|
||||
dvc.odb.local, PathInfo(tmp_dir) / "dir", fs, "md5"
|
||||
).hash_info
|
||||
@@ -553,7 +553,7 @@ def test_get_hash_dirty_file(tmp_dir, dvc):
|
||||
tmp_dir.dvc_gen("file", "file")
|
||||
(tmp_dir / "file").write_text("something")
|
||||
|
||||
fs = RepoFileSystem(dvc)
|
||||
fs = RepoFileSystem(repo=dvc)
|
||||
assert fs.info(PathInfo(tmp_dir) / "file").get("md5") is None
|
||||
actual = stage(
|
||||
dvc.odb.local, PathInfo(tmp_dir) / "file", fs, "md5"
|
||||
@@ -577,7 +577,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 = RepoFileSystem(dvc)
|
||||
fs = RepoFileSystem(repo=dvc)
|
||||
actual = stage(
|
||||
dvc.odb.local, PathInfo(tmp_dir) / "dir", fs, "md5"
|
||||
).hash_info
|
||||
@@ -631,7 +631,7 @@ def test_walk_nested_subrepos(tmp_dir, dvc, scm, traverse_subrepos):
|
||||
expected[str(tmp_dir / "subrepo1")].add("subrepo3")
|
||||
|
||||
actual = {}
|
||||
fs = RepoFileSystem(dvc)
|
||||
fs = RepoFileSystem(repo=dvc)
|
||||
for root, dirs, files in fs.walk(
|
||||
str(tmp_dir), ignore_subrepos=not traverse_subrepos
|
||||
):
|
||||
|
||||
+15
-18
@@ -28,7 +28,7 @@ def grants():
|
||||
|
||||
def test_init(dvc):
|
||||
config = {"url": url}
|
||||
fs = S3FileSystem(dvc, config)
|
||||
fs = S3FileSystem(**config)
|
||||
|
||||
assert fs.path_info == url
|
||||
|
||||
@@ -37,7 +37,7 @@ def test_verify_ssl_default_param(dvc):
|
||||
config = {
|
||||
"url": url,
|
||||
}
|
||||
fs = S3FileSystem(dvc, config)
|
||||
fs = S3FileSystem(**config)
|
||||
|
||||
assert fs.fs_args["client_kwargs"]["verify"]
|
||||
|
||||
@@ -47,12 +47,12 @@ def test_s3_config_credentialpath(dvc, monkeypatch):
|
||||
monkeypatch.setattr(os, "environ", environment)
|
||||
|
||||
config = {"url": url, "credentialpath": "somewhere"}
|
||||
S3FileSystem(dvc, config)
|
||||
S3FileSystem(**config)
|
||||
assert environment["AWS_SHARED_CREDENTIALS_FILE"] == "somewhere"
|
||||
environment.clear()
|
||||
|
||||
config = {"url": url, "configpath": "somewhere"}
|
||||
S3FileSystem(dvc, config)
|
||||
S3FileSystem(**config)
|
||||
assert environment["AWS_CONFIG_FILE"] == "somewhere"
|
||||
environment.clear()
|
||||
|
||||
@@ -61,7 +61,7 @@ def test_s3_config_credentialpath(dvc, monkeypatch):
|
||||
"credentialpath": "somewhere",
|
||||
"configpath": "elsewhere",
|
||||
}
|
||||
S3FileSystem(dvc, config)
|
||||
S3FileSystem(**config)
|
||||
assert environment["AWS_SHARED_CREDENTIALS_FILE"] == "somewhere"
|
||||
assert environment["AWS_CONFIG_FILE"] == "elsewhere"
|
||||
environment.clear()
|
||||
@@ -69,7 +69,7 @@ def test_s3_config_credentialpath(dvc, monkeypatch):
|
||||
|
||||
def test_ssl_verify_bool_param(dvc):
|
||||
config = {"url": url, "ssl_verify": False}
|
||||
fs = S3FileSystem(dvc, config)
|
||||
fs = S3FileSystem(**config)
|
||||
|
||||
assert fs.fs_args["client_kwargs"]["verify"] == config["ssl_verify"]
|
||||
|
||||
@@ -82,7 +82,7 @@ def test_grants(dvc):
|
||||
"grant_write_acp": "id=write-acp-permission-id",
|
||||
"grant_full_control": "id=full-control-permission-id",
|
||||
}
|
||||
fs = S3FileSystem(dvc, config)
|
||||
fs = S3FileSystem(**config)
|
||||
|
||||
extra_args = fs.fs_args["s3_additional_kwargs"]
|
||||
assert (
|
||||
@@ -99,23 +99,20 @@ def test_grants_mutually_exclusive_acl_error(dvc, grants):
|
||||
config = {"url": url, "acl": "public-read", grant_option: grant_value}
|
||||
|
||||
with pytest.raises(ConfigError):
|
||||
S3FileSystem(dvc, config)
|
||||
S3FileSystem(**config)
|
||||
|
||||
|
||||
def test_sse_kms_key_id(dvc):
|
||||
fs = S3FileSystem(dvc, {"url": url, "sse_kms_key_id": "key"})
|
||||
fs = S3FileSystem(url=url, sse_kms_key_id="key")
|
||||
assert fs.fs_args["s3_additional_kwargs"]["SSEKMSKeyId"] == "key"
|
||||
|
||||
|
||||
def test_key_id_and_secret(dvc):
|
||||
fs = S3FileSystem(
|
||||
dvc,
|
||||
{
|
||||
"url": url,
|
||||
"access_key_id": key_id,
|
||||
"secret_access_key": key_secret,
|
||||
"session_token": session_token,
|
||||
},
|
||||
url=url,
|
||||
access_key_id=key_id,
|
||||
secret_access_key=key_secret,
|
||||
session_token=session_token,
|
||||
)
|
||||
assert fs.fs_args["key"] == key_id
|
||||
assert fs.fs_args["secret"] == key_secret
|
||||
@@ -154,7 +151,7 @@ def test_s3_aws_config(tmp_dir, dvc, s3, monkeypatch):
|
||||
m.setenv(var, str(tmp_dir))
|
||||
# Fresh import to see the effects of changing HOME variable
|
||||
s3_mod = importlib.reload(sys.modules[S3FileSystem.__module__])
|
||||
fs = s3_mod.S3FileSystem(dvc, s3.config)
|
||||
fs = s3_mod.S3FileSystem(**s3.config)
|
||||
|
||||
importlib.reload(sys.modules[S3FileSystem.__module__])
|
||||
|
||||
@@ -190,7 +187,7 @@ def test_s3_aws_config_different_profile(tmp_dir, dvc, s3, monkeypatch):
|
||||
)
|
||||
monkeypatch.setenv("AWS_CONFIG_FILE", config_file)
|
||||
|
||||
fs = S3FileSystem(dvc, {**s3.config, "profile": "dev"})
|
||||
fs = S3FileSystem(profile="dev", **s3.config)
|
||||
|
||||
s3_config = fs.fs_args["config_kwargs"]["s3"]
|
||||
assert s3_config["addressing_style"] == "virtual"
|
||||
|
||||
@@ -16,9 +16,12 @@ def test_get_cloud_fs(tmp_dir, dvc):
|
||||
first = base / "first"
|
||||
second = first / "second"
|
||||
|
||||
assert get_cloud_fs(dvc, name="base").path_info == base
|
||||
assert get_cloud_fs(dvc, name="first").path_info == first
|
||||
assert get_cloud_fs(dvc, name="second").path_info == second
|
||||
cls, config = get_cloud_fs(dvc, name="base")
|
||||
assert cls(**config).path_info == base
|
||||
cls, config = get_cloud_fs(dvc, name="first")
|
||||
assert cls(**config).path_info == first
|
||||
cls, config = get_cloud_fs(dvc, name="second")
|
||||
assert cls(**config).path_info == second
|
||||
|
||||
|
||||
def test_get_cloud_fs_validate(tmp_dir, dvc):
|
||||
@@ -36,10 +39,10 @@ def test_get_cloud_fs_validate(tmp_dir, dvc):
|
||||
default=False,
|
||||
)
|
||||
|
||||
assert get_cloud_fs(dvc, name="base").config == {
|
||||
assert get_cloud_fs(dvc, name="base")[1] == {
|
||||
"url": "ssh://example.com/path"
|
||||
}
|
||||
assert get_cloud_fs(dvc, name="first").config == {
|
||||
assert get_cloud_fs(dvc, name="first")[1] == {
|
||||
"url": "ssh://example.com/path/first",
|
||||
"type": ["symlink"],
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ def test_status_download_optimization(mocker, dvc):
|
||||
And the desired files to fetch are already on the local cache,
|
||||
Don't check the existence of the desired files on the remote cache
|
||||
"""
|
||||
odb = LocalObjectDB(LocalFileSystem(dvc, {}))
|
||||
odb = LocalObjectDB(LocalFileSystem())
|
||||
|
||||
infos = NamedCache()
|
||||
infos.add("local", "acbd18db4cc2f85cedef654fccc4a4d8", "foo")
|
||||
|
||||
@@ -19,20 +19,20 @@ def test_url(dvc):
|
||||
url = f"ssh://{user}@{host}:{port}{path}"
|
||||
config = {"url": url}
|
||||
|
||||
fs = SSHFileSystem(dvc, config)
|
||||
fs = SSHFileSystem(**config)
|
||||
assert fs.path_info == url
|
||||
|
||||
# SCP-like URL ssh://[user@]host.xz:/absolute/path
|
||||
url = f"ssh://{user}@{host}:{path}"
|
||||
config = {"url": url}
|
||||
|
||||
fs = SSHFileSystem(dvc, config)
|
||||
fs = SSHFileSystem(**config)
|
||||
assert fs.path_info == url
|
||||
|
||||
|
||||
def test_no_path(dvc):
|
||||
config = {"url": "ssh://127.0.0.1"}
|
||||
fs = SSHFileSystem(dvc, config)
|
||||
fs = SSHFileSystem(**config)
|
||||
assert fs.path_info.path == ""
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ else:
|
||||
def test_ssh_host_override_from_config(
|
||||
mock_file, mock_exists, dvc, config, expected_host
|
||||
):
|
||||
fs = SSHFileSystem(dvc, config)
|
||||
fs = SSHFileSystem(**config)
|
||||
|
||||
mock_exists.assert_called_with(SSHFileSystem.ssh_config_filename())
|
||||
mock_file.assert_called_with(SSHFileSystem.ssh_config_filename())
|
||||
@@ -94,7 +94,7 @@ def test_ssh_host_override_from_config(
|
||||
read_data=mock_ssh_config,
|
||||
)
|
||||
def test_ssh_user(mock_file, mock_exists, dvc, config, expected_user):
|
||||
fs = SSHFileSystem(dvc, config)
|
||||
fs = SSHFileSystem(**config)
|
||||
|
||||
mock_exists.assert_called_with(SSHFileSystem.ssh_config_filename())
|
||||
mock_file.assert_called_with(SSHFileSystem.ssh_config_filename())
|
||||
@@ -119,7 +119,7 @@ def test_ssh_user(mock_file, mock_exists, dvc, config, expected_user):
|
||||
read_data=mock_ssh_config,
|
||||
)
|
||||
def test_ssh_port(mock_file, mock_exists, dvc, config, expected_port):
|
||||
fs = SSHFileSystem(dvc, config)
|
||||
fs = SSHFileSystem(**config)
|
||||
|
||||
mock_exists.assert_called_with(SSHFileSystem.ssh_config_filename())
|
||||
mock_file.assert_called_with(SSHFileSystem.ssh_config_filename())
|
||||
@@ -154,7 +154,7 @@ def test_ssh_port(mock_file, mock_exists, dvc, config, expected_port):
|
||||
read_data=mock_ssh_config,
|
||||
)
|
||||
def test_ssh_keyfile(mock_file, mock_exists, dvc, config, expected_keyfile):
|
||||
fs = SSHFileSystem(dvc, config)
|
||||
fs = SSHFileSystem(**config)
|
||||
|
||||
mock_exists.assert_called_with(SSHFileSystem.ssh_config_filename())
|
||||
mock_file.assert_called_with(SSHFileSystem.ssh_config_filename())
|
||||
@@ -176,7 +176,7 @@ def test_ssh_keyfile(mock_file, mock_exists, dvc, config, expected_keyfile):
|
||||
read_data=mock_ssh_config,
|
||||
)
|
||||
def test_ssh_gss_auth(mock_file, mock_exists, dvc, config, expected_gss_auth):
|
||||
fs = SSHFileSystem(dvc, config)
|
||||
fs = SSHFileSystem(**config)
|
||||
|
||||
mock_exists.assert_called_with(SSHFileSystem.ssh_config_filename())
|
||||
mock_file.assert_called_with(SSHFileSystem.ssh_config_filename())
|
||||
@@ -201,7 +201,7 @@ def test_ssh_gss_auth(mock_file, mock_exists, dvc, config, expected_gss_auth):
|
||||
def test_ssh_allow_agent(
|
||||
mock_file, mock_exists, dvc, config, expected_allow_agent
|
||||
):
|
||||
fs = SSHFileSystem(dvc, config)
|
||||
fs = SSHFileSystem(**config)
|
||||
|
||||
mock_exists.assert_called_with(SSHFileSystem.ssh_config_filename())
|
||||
mock_file.assert_called_with(SSHFileSystem.ssh_config_filename())
|
||||
@@ -209,7 +209,7 @@ def test_ssh_allow_agent(
|
||||
|
||||
|
||||
def test_hardlink_optimization(dvc, tmp_dir, ssh):
|
||||
fs = SSHFileSystem(dvc, ssh.config)
|
||||
fs = SSHFileSystem(**ssh.config)
|
||||
|
||||
from_info = fs.path_info / "empty"
|
||||
to_info = fs.path_info / "link"
|
||||
|
||||
@@ -31,13 +31,13 @@ def test_cmd_error(dvc):
|
||||
side_effect=RemoteCmdError("base", cmd, ret, err),
|
||||
):
|
||||
with pytest.raises(RemoteCmdError):
|
||||
BaseFileSystem(dvc, config).remove("file")
|
||||
BaseFileSystem(**config).remove("file")
|
||||
|
||||
|
||||
@mock.patch.object(ObjectDB, "list_hashes_traverse")
|
||||
@mock.patch.object(ObjectDB, "list_hashes_exists")
|
||||
def test_hashes_exist(object_exists, traverse, dvc):
|
||||
odb = ObjectDB(BaseFileSystem(dvc, {}))
|
||||
odb = ObjectDB(BaseFileSystem())
|
||||
|
||||
# remote does not support traverse
|
||||
odb.fs.CAN_TRAVERSE = False
|
||||
@@ -90,7 +90,7 @@ def test_hashes_exist(object_exists, traverse, dvc):
|
||||
ObjectDB, "_path_to_hash", side_effect=lambda x: x,
|
||||
)
|
||||
def test_list_hashes_traverse(_path_to_hash, list_hashes, dvc):
|
||||
odb = ObjectDB(BaseFileSystem(dvc, {}))
|
||||
odb = ObjectDB(BaseFileSystem())
|
||||
odb.fs.path_info = PathInfo("foo")
|
||||
|
||||
# parallel traverse
|
||||
@@ -115,7 +115,7 @@ def test_list_hashes_traverse(_path_to_hash, list_hashes, dvc):
|
||||
|
||||
|
||||
def test_list_hashes(dvc):
|
||||
odb = ObjectDB(BaseFileSystem(dvc, {}))
|
||||
odb = ObjectDB(BaseFileSystem())
|
||||
odb.fs.path_info = PathInfo("foo")
|
||||
|
||||
with mock.patch.object(
|
||||
@@ -126,7 +126,7 @@ def test_list_hashes(dvc):
|
||||
|
||||
|
||||
def test_list_paths(dvc):
|
||||
odb = ObjectDB(BaseFileSystem(dvc, {}))
|
||||
odb = ObjectDB(BaseFileSystem())
|
||||
odb.fs.path_info = PathInfo("foo")
|
||||
|
||||
with mock.patch.object(odb.fs, "walk_files", return_value=[]) as walk_mock:
|
||||
|
||||
@@ -15,11 +15,15 @@ class TestRemoteGDrive:
|
||||
}
|
||||
|
||||
def test_init(self, dvc):
|
||||
fs = GDriveFileSystem(dvc, self.CONFIG)
|
||||
fs = GDriveFileSystem(
|
||||
gdrive_credentials_tmp_dir=dvc.tmp_dir, **self.CONFIG
|
||||
)
|
||||
assert str(fs.path_info) == self.CONFIG["url"]
|
||||
|
||||
def test_drive(self, dvc, monkeypatch):
|
||||
fs = GDriveFileSystem(dvc, self.CONFIG)
|
||||
fs = GDriveFileSystem(
|
||||
gdrive_credentials_tmp_dir=dvc.tmp_dir, **self.CONFIG
|
||||
)
|
||||
monkeypatch.setenv(
|
||||
GDriveFileSystem.GDRIVE_CREDENTIALS_DATA,
|
||||
USER_CREDS_TOKEN_REFRESH_ERROR,
|
||||
@@ -28,7 +32,9 @@ class TestRemoteGDrive:
|
||||
assert fs._drive
|
||||
|
||||
monkeypatch.setenv(GDriveFileSystem.GDRIVE_CREDENTIALS_DATA, "")
|
||||
fs = GDriveFileSystem(dvc, self.CONFIG)
|
||||
fs = GDriveFileSystem(
|
||||
gdrive_credentials_tmp_dir=dvc.tmp_dir, **self.CONFIG
|
||||
)
|
||||
monkeypatch.setenv(
|
||||
GDriveFileSystem.GDRIVE_CREDENTIALS_DATA,
|
||||
USER_CREDS_MISSED_KEY_ERROR,
|
||||
|
||||
@@ -9,7 +9,7 @@ from dvc.path_info import URLInfo
|
||||
|
||||
|
||||
def test_download_fails_on_error_code(dvc, http):
|
||||
fs = HTTPFileSystem(dvc, http.config)
|
||||
fs = HTTPFileSystem(**http.config)
|
||||
|
||||
with pytest.raises(HTTPError):
|
||||
fs._download(http / "missing.txt", "missing.txt")
|
||||
@@ -23,7 +23,7 @@ def test_public_auth_method(dvc):
|
||||
"password": "",
|
||||
}
|
||||
|
||||
fs = HTTPFileSystem(dvc, config)
|
||||
fs = HTTPFileSystem(**config)
|
||||
|
||||
assert fs._auth_method() is None
|
||||
|
||||
@@ -42,7 +42,7 @@ def test_basic_auth_method(dvc):
|
||||
"password": password,
|
||||
}
|
||||
|
||||
fs = HTTPFileSystem(dvc, config)
|
||||
fs = HTTPFileSystem(**config)
|
||||
|
||||
assert fs._auth_method() == auth
|
||||
assert isinstance(fs._auth_method(), HTTPBasicAuth)
|
||||
@@ -62,7 +62,7 @@ def test_digest_auth_method(dvc):
|
||||
"password": password,
|
||||
}
|
||||
|
||||
fs = HTTPFileSystem(dvc, config)
|
||||
fs = HTTPFileSystem(**config)
|
||||
|
||||
assert fs._auth_method() == auth
|
||||
assert isinstance(fs._auth_method(), HTTPDigestAuth)
|
||||
@@ -79,7 +79,7 @@ def test_custom_auth_method(dvc):
|
||||
"password": password,
|
||||
}
|
||||
|
||||
fs = HTTPFileSystem(dvc, config)
|
||||
fs = HTTPFileSystem(**config)
|
||||
|
||||
assert fs._auth_method() is None
|
||||
assert header in fs.headers
|
||||
@@ -92,7 +92,7 @@ def test_ssl_verify_is_enabled_by_default(dvc):
|
||||
"path_info": "file.html",
|
||||
}
|
||||
|
||||
fs = HTTPFileSystem(dvc, config)
|
||||
fs = HTTPFileSystem(**config)
|
||||
|
||||
assert fs._session.verify is True
|
||||
|
||||
@@ -104,7 +104,7 @@ def test_ssl_verify_disable(dvc):
|
||||
"ssl_verify": False,
|
||||
}
|
||||
|
||||
fs = HTTPFileSystem(dvc, config)
|
||||
fs = HTTPFileSystem(**config)
|
||||
|
||||
assert fs._session.verify is False
|
||||
|
||||
@@ -124,7 +124,7 @@ def test_http_method(dvc):
|
||||
"method": "PUT",
|
||||
}
|
||||
|
||||
fs = HTTPFileSystem(dvc, config)
|
||||
fs = HTTPFileSystem(**config)
|
||||
|
||||
assert fs._auth_method() == auth
|
||||
assert fs.method == "PUT"
|
||||
@@ -137,7 +137,7 @@ def test_exists(mocker):
|
||||
# on HEAD request failure.
|
||||
res.raw = io.StringIO("foo")
|
||||
|
||||
fs = HTTPFileSystem(None, {})
|
||||
fs = HTTPFileSystem()
|
||||
mocker.patch.object(fs, "request", return_value=res)
|
||||
|
||||
url = URLInfo("https://example.org/file.txt")
|
||||
@@ -161,7 +161,7 @@ def test_content_length(mocker, headers, expected_size):
|
||||
res.headers.update(headers)
|
||||
res.status_code = 200
|
||||
|
||||
fs = HTTPFileSystem(None, {})
|
||||
fs = HTTPFileSystem()
|
||||
mocker.patch.object(fs, "request", return_value=res)
|
||||
|
||||
url = URLInfo("https://example.org/file.txt")
|
||||
|
||||
@@ -8,7 +8,7 @@ from dvc.remote.index import RemoteIndex
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def index(dvc):
|
||||
idx = RemoteIndex(dvc, "foo")
|
||||
idx = RemoteIndex(dvc.tmp_dir, "foo")
|
||||
idx.load()
|
||||
yield idx
|
||||
idx.dump()
|
||||
|
||||
@@ -15,7 +15,7 @@ def test_init(dvc):
|
||||
"oss_key_secret": key_secret,
|
||||
"oss_endpoint": endpoint,
|
||||
}
|
||||
fs = OSSFileSystem(dvc, config)
|
||||
fs = OSSFileSystem(**config)
|
||||
assert fs.path_info == url
|
||||
assert fs.endpoint == endpoint
|
||||
assert fs.key_id == key_id
|
||||
|
||||
@@ -12,7 +12,8 @@ def test_remote_with_hash_jobs(dvc):
|
||||
}
|
||||
dvc.config["core"]["checksum_jobs"] = 200
|
||||
|
||||
fs = get_cloud_fs(dvc, name="with_hash_jobs")
|
||||
cls, config = get_cloud_fs(dvc, name="with_hash_jobs")
|
||||
fs = cls(**config)
|
||||
assert fs.hash_jobs == 100
|
||||
|
||||
|
||||
@@ -23,7 +24,8 @@ def test_remote_with_jobs(dvc):
|
||||
}
|
||||
dvc.config["core"]["jobs"] = 200
|
||||
|
||||
fs = get_cloud_fs(dvc, name="with_jobs")
|
||||
cls, config = get_cloud_fs(dvc, name="with_jobs")
|
||||
fs = cls(**config)
|
||||
assert fs.jobs == 100
|
||||
|
||||
|
||||
@@ -31,21 +33,23 @@ def test_remote_without_hash_jobs(dvc):
|
||||
dvc.config["remote"]["without_hash_jobs"] = {"url": "s3://bucket/name"}
|
||||
dvc.config["core"]["checksum_jobs"] = 200
|
||||
|
||||
fs = get_cloud_fs(dvc, name="without_hash_jobs")
|
||||
cls, config = get_cloud_fs(dvc, name="without_hash_jobs")
|
||||
fs = cls(**config)
|
||||
assert fs.hash_jobs == 200
|
||||
|
||||
|
||||
def test_remote_without_hash_jobs_default(dvc):
|
||||
dvc.config["remote"]["without_hash_jobs"] = {"url": "s3://bucket/name"}
|
||||
|
||||
fs = get_cloud_fs(dvc, name="without_hash_jobs")
|
||||
cls, config = get_cloud_fs(dvc, name="without_hash_jobs")
|
||||
fs = cls(**config)
|
||||
assert fs.hash_jobs == fs.HASH_JOBS
|
||||
|
||||
|
||||
@pytest.mark.parametrize("fs_cls", [GSFileSystem, S3FileSystem])
|
||||
def test_makedirs_not_create_for_top_level_path(fs_cls, dvc, mocker):
|
||||
url = f"{fs_cls.scheme}://bucket/"
|
||||
fs = fs_cls(dvc, {"url": url})
|
||||
fs = fs_cls(url=url)
|
||||
mocked_client = mocker.PropertyMock()
|
||||
mocker.patch.object(fs_cls, "fs", mocked_client)
|
||||
|
||||
|
||||
@@ -87,21 +87,25 @@ def test_walk_files(remote):
|
||||
assert list(remote.fs.walk_files(remote.fs.path_info / "data")) == files
|
||||
|
||||
|
||||
@pytest.mark.parametrize("remote", [pytest.lazy_fixture("s3")], indirect=True)
|
||||
def test_copy_preserve_etag_across_buckets(remote, dvc):
|
||||
s3 = remote.fs
|
||||
@pytest.mark.parametrize("cloud", [pytest.lazy_fixture("s3")])
|
||||
def test_copy_preserve_etag_across_buckets(cloud, dvc):
|
||||
cloud.gen(FILE_WITH_CONTENTS)
|
||||
rem = get_remote(dvc, **cloud.config)
|
||||
s3 = rem.fs
|
||||
s3.fs.mkdir("another/")
|
||||
|
||||
another = S3FileSystem(
|
||||
dvc, {**remote.fs.config, "url": "s3://another", "region": "us-east-1"}
|
||||
)
|
||||
config = cloud.config.copy()
|
||||
config["url"] = "s3://another"
|
||||
config["region"] = "us-east-1"
|
||||
|
||||
from_info = remote.fs.path_info / "foo"
|
||||
another = S3FileSystem(**config)
|
||||
|
||||
from_info = rem.fs.path_info / "foo"
|
||||
to_info = another.path_info / "foo"
|
||||
|
||||
remote.fs.copy(from_info, to_info)
|
||||
rem.fs.copy(from_info, to_info)
|
||||
|
||||
from_hash = remote.fs.info(from_info)["etag"]
|
||||
from_hash = rem.fs.info(from_info)["etag"]
|
||||
to_hash = another.info(to_info)["etag"]
|
||||
|
||||
assert from_hash == to_hash
|
||||
|
||||
@@ -14,9 +14,8 @@ def timeout_immediately(monkeypatch):
|
||||
def make_remote():
|
||||
def _make_remote(cache_type=None, should_warn=True):
|
||||
remote = mock.Mock()
|
||||
remote.repo.config = {
|
||||
"cache": {"type": cache_type, "slow_link_warning": should_warn}
|
||||
}
|
||||
remote.cache_types = cache_type
|
||||
remote.slow_link_warning = should_warn
|
||||
return remote
|
||||
|
||||
return _make_remote
|
||||
|
||||
@@ -12,7 +12,7 @@ password = "password"
|
||||
# Test minimum requiered configuration (url)
|
||||
def test_init(dvc):
|
||||
config = {"url": url}
|
||||
fs = WebDAVFileSystem(dvc, config)
|
||||
fs = WebDAVFileSystem(**config)
|
||||
|
||||
assert fs.path_info == url
|
||||
|
||||
@@ -22,7 +22,7 @@ def test_init(dvc):
|
||||
"config", [{"url": url, "user": user}, {"url": userurl}]
|
||||
)
|
||||
def test_user(dvc, config):
|
||||
fs = WebDAVFileSystem(dvc, config)
|
||||
fs = WebDAVFileSystem(**config)
|
||||
|
||||
assert fs.user == user
|
||||
|
||||
@@ -30,7 +30,7 @@ def test_user(dvc, config):
|
||||
# Test username extraction from url
|
||||
def test_userurl(dvc):
|
||||
config = {"url": userurl}
|
||||
fs = WebDAVFileSystem(dvc, config)
|
||||
fs = WebDAVFileSystem(**config)
|
||||
|
||||
assert fs.path_info == userurl
|
||||
assert fs.user == user
|
||||
@@ -40,6 +40,6 @@ def test_userurl(dvc):
|
||||
# test password from config
|
||||
def test_password(dvc):
|
||||
config = {"url": url, "user": user, "password": password}
|
||||
fs = WebDAVFileSystem(dvc, config)
|
||||
fs = WebDAVFileSystem(**config)
|
||||
|
||||
assert fs.password == password
|
||||
|
||||
@@ -16,7 +16,7 @@ def test_init(dvc):
|
||||
"user": user,
|
||||
}
|
||||
|
||||
fs = WebHDFSFileSystem(dvc, config)
|
||||
fs = WebHDFSFileSystem(**config)
|
||||
assert fs.path_info == url
|
||||
assert fs.token == webhdfs_token
|
||||
assert fs.alias == webhdfs_alias
|
||||
|
||||
@@ -288,7 +288,7 @@ def test_track(tmp_dir):
|
||||
],
|
||||
"dct": {"foo": "foo", "bar": "bar", "baz": "baz"},
|
||||
}
|
||||
fs = LocalFileSystem(None, config={})
|
||||
fs = LocalFileSystem()
|
||||
path = tmp_dir / "params.yaml"
|
||||
dump_yaml(path, d, fs)
|
||||
|
||||
@@ -323,7 +323,7 @@ def test_track_from_multiple_files(tmp_dir):
|
||||
d1 = {"Train": {"us": {"lr": 10}}}
|
||||
d2 = {"Train": {"us": {"layers": 100}}}
|
||||
|
||||
fs = LocalFileSystem(None, config={})
|
||||
fs = LocalFileSystem()
|
||||
path1 = tmp_dir / "params.yaml"
|
||||
path2 = tmp_dir / "params2.yaml"
|
||||
dump_yaml(path1, d1, fs)
|
||||
|
||||
@@ -28,7 +28,7 @@ from tests.basic_env import TestDir
|
||||
|
||||
class TestMtimeAndSize(TestDir):
|
||||
def test(self):
|
||||
fs = LocalFileSystem(None, {"url": self.root_dir})
|
||||
fs = LocalFileSystem(url=self.root_dir)
|
||||
file_time, file_size = get_mtime_and_size(self.DATA, fs)
|
||||
dir_time, dir_size = get_mtime_and_size(self.DATA_DIR, fs)
|
||||
|
||||
@@ -129,7 +129,7 @@ def test_path_object_and_str_are_valid_types_get_mtime_and_size(tmp_dir):
|
||||
tmp_dir.gen(
|
||||
{"dir": {"dir_file": "dir file content"}, "file": "file_content"}
|
||||
)
|
||||
fs = LocalFileSystem(None, {"url": os.fspath(tmp_dir)})
|
||||
fs = LocalFileSystem(url=os.fspath(tmp_dir))
|
||||
|
||||
time, size = get_mtime_and_size("dir", fs)
|
||||
object_time, object_size = get_mtime_and_size(PathInfo("dir"), fs)
|
||||
|
||||
@@ -19,7 +19,7 @@ def test_hashed_stream_reader(tmp_dir):
|
||||
assert stream_reader.read(1) == b"o"
|
||||
assert stream_reader.tell() == 3
|
||||
|
||||
hex_digest = file_md5(foo, LocalFileSystem(None, {}))
|
||||
hex_digest = file_md5(foo, LocalFileSystem())
|
||||
assert stream_reader.is_text_file
|
||||
assert hex_digest == stream_reader.hash_info.value
|
||||
|
||||
@@ -43,6 +43,6 @@ def test_hashed_stream_reader_as_chunks(tmp_dir):
|
||||
|
||||
assert stream_reader.tell() == actual_size == total_read
|
||||
|
||||
hex_digest = file_md5(foo, LocalFileSystem(None, {}))
|
||||
hex_digest = file_md5(foo, LocalFileSystem())
|
||||
assert not stream_reader.is_text_file
|
||||
assert hex_digest == stream_reader.hash_info.value
|
||||
|
||||
@@ -87,7 +87,7 @@ def test_fix_env_pyenv(path, orig):
|
||||
def test_file_md5(tmp_dir):
|
||||
tmp_dir.gen("foo", "foo content")
|
||||
|
||||
fs = LocalFileSystem(None, {})
|
||||
fs = LocalFileSystem()
|
||||
assert file_md5("foo", fs) == file_md5(PathInfo("foo"), fs)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user