repofs: use repo paths

This commit is contained in:
Ruslan Kuprieiev
2022-04-18 14:17:20 +03:00
parent b3b0ec1fba
commit 9d75e8261b
20 changed files with 214 additions and 200 deletions
+10 -10
View File
@@ -32,9 +32,9 @@ def test_new_checkpoint(
if rev == "workspace":
continue
fs = dvc.repo_fs
with fs.open((tmp_dir / "foo").fs_path) as fobj:
with fs.open("foo") as fobj:
assert fobj.read().strip() == str(checkpoint_stage.iterations)
with fs.open((tmp_dir / "metrics.yaml").fs_path) as fobj:
with fs.open("metrics.yaml") as fobj:
assert fobj.read().strip() == "foo: 2"
if workspace:
@@ -81,9 +81,9 @@ def test_resume_checkpoint(
if rev == "workspace":
continue
fs = dvc.repo_fs
with fs.open((tmp_dir / "foo").fs_path) as fobj:
with fs.open("foo") as fobj:
assert fobj.read().strip() == str(2 * checkpoint_stage.iterations)
with fs.open((tmp_dir / "metrics.yaml").fs_path) as fobj:
with fs.open("metrics.yaml") as fobj:
assert fobj.read().strip() == "foo: 2"
if workspace:
@@ -112,9 +112,9 @@ def test_reset_checkpoint(
if rev == "workspace":
continue
fs = dvc.repo_fs
with fs.open((tmp_dir / "foo").fs_path) as fobj:
with fs.open("foo") as fobj:
assert fobj.read().strip() == str(checkpoint_stage.iterations)
with fs.open((tmp_dir / "metrics.yaml").fs_path) as fobj:
with fs.open("metrics.yaml") as fobj:
assert fobj.read().strip() == "foo: 2"
if workspace:
@@ -151,18 +151,18 @@ def test_resume_branch(tmp_dir, scm, dvc, checkpoint_stage, workspace):
if rev == "workspace":
continue
fs = dvc.repo_fs
with fs.open((tmp_dir / "foo").fs_path) as fobj:
with fs.open("foo") as fobj:
assert fobj.read().strip() == str(2 * checkpoint_stage.iterations)
with fs.open((tmp_dir / "metrics.yaml").fs_path) as fobj:
with fs.open("metrics.yaml") as fobj:
assert fobj.read().strip() == "foo: 2"
for rev in dvc.brancher([checkpoint_b]):
if rev == "workspace":
continue
fs = dvc.repo_fs
with fs.open((tmp_dir / "foo").fs_path) as fobj:
with fs.open("foo") as fobj:
assert fobj.read().strip() == str(2 * checkpoint_stage.iterations)
with fs.open((tmp_dir / "metrics.yaml").fs_path) as fobj:
with fs.open("metrics.yaml") as fobj:
assert fobj.read().strip() == "foo: 100"
with pytest.raises(MultipleBranchError):
+2 -2
View File
@@ -675,9 +675,9 @@ def test_modified_data_dep(tmp_dir, scm, dvc, workspace, params, target):
for rev in dvc.brancher(revs=[exp]):
if rev != exp:
continue
with dvc.repo_fs.open((tmp_dir / "metrics.yaml").fs_path) as fobj:
with dvc.repo_fs.open("metrics.yaml") as fobj:
assert fobj.read().strip() == params
with dvc.repo_fs.open((tmp_dir / "data").fs_path) as fobj:
with dvc.repo_fs.open("data") as fobj:
assert fobj.read().strip() == "modified"
if workspace:
+4 -4
View File
@@ -96,7 +96,7 @@ def test_pull_subdir_file(tmp_dir, erepo_dir):
dest = tmp_dir / "file"
with external_repo(os.fspath(erepo_dir)) as repo:
repo.repo_fs.download(
os.path.join(repo.root_dir, "subdir", "file"),
os.path.join("subdir", "file"),
os.fspath(dest),
)
@@ -192,7 +192,7 @@ def test_subrepos_are_ignored(tmp_dir, erepo_dir):
with external_repo(os.fspath(erepo_dir)) as repo:
repo.repo_fs.download(
os.path.join(repo.root_dir, "dir"),
"dir",
os.fspath(tmp_dir / "out"),
)
expected_files = {"foo": "foo", "bar": "bar", ".gitignore": "/foo\n"}
@@ -206,7 +206,7 @@ def test_subrepos_are_ignored(tmp_dir, erepo_dir):
staging, _, obj = stage(
repo.odb.local,
os.path.join(repo.root_dir, "dir"),
"dir",
repo.repo_fs,
"md5",
dvcignore=repo.dvcignore,
@@ -238,7 +238,7 @@ def test_subrepos_are_ignored_for_git_tracked_dirs(tmp_dir, erepo_dir):
with external_repo(os.fspath(erepo_dir)) as repo:
repo.repo_fs.download(
os.path.join(repo.root_dir, "dir"),
"dir",
os.fspath(tmp_dir / "out"),
)
# subrepo files should not be here
+3 -3
View File
@@ -335,7 +335,7 @@ def test_callback_on_repo_fs(tmp_dir, dvc, scm):
callback = fsspec.Callback()
fs.download(
(tmp_dir / "dir").fs_path,
"dir",
(tmp_dir / "dir2").fs_path,
callback=callback,
)
@@ -346,7 +346,7 @@ def test_callback_on_repo_fs(tmp_dir, dvc, scm):
callback = fsspec.Callback()
fs.download(
(tmp_dir / "dir" / "foo").fs_path,
os.path.join("dir", "foo"),
(tmp_dir / "foo").fs_path,
callback=callback,
)
@@ -358,7 +358,7 @@ def test_callback_on_repo_fs(tmp_dir, dvc, scm):
callback = fsspec.Callback()
fs.download(
(tmp_dir / "dir" / "bar").fs_path,
os.path.join("dir", "bar"),
(tmp_dir / "bar").fs_path,
callback=callback,
)