Skip to content

Commit

Permalink
deps: bump dvc-data to 0.0.20
Browse files Browse the repository at this point in the history
  • Loading branch information
efiop committed Jul 8, 2022
1 parent 182a22b commit 8b3020a
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 54 deletions.
2 changes: 1 addition & 1 deletion dvc/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def _log_exceptions(exc: Exception) -> Optional[int]:
)
return None

from dvc_data.stage import IgnoreInCollectedDirError
from dvc_data.build import IgnoreInCollectedDirError

if isinstance(exc, IgnoreInCollectedDirError):
logger.exception("")
Expand Down
24 changes: 12 additions & 12 deletions dvc/dependency/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class RepoDependency(Dependency):

def __init__(self, def_repo, stage, *args, **kwargs):
self.def_repo = def_repo
self._staged_objs: Dict[str, "HashFile"] = {}
self._objs: Dict[str, "HashFile"] = {}
super().__init__(stage, *args, **kwargs)

def _parse_path(self, fs, fs_path):
Expand Down Expand Up @@ -103,8 +103,8 @@ def _get_used_and_obj(
from dvc.config import NoRemoteError
from dvc.exceptions import NoOutputOrStageError, PathMissingError
from dvc.utils import as_posix
from dvc_data.build import build
from dvc_data.objects.tree import Tree, TreeError
from dvc_data.stage import stage

local_odb = self.repo.odb.local
locked = kwargs.pop("locked", True)
Expand Down Expand Up @@ -133,7 +133,7 @@ def _get_used_and_obj(
pass

try:
staging, _, staged_obj = stage(
object_store, _, obj = build(
local_odb,
as_posix(self.def_path),
repo.dvcfs,
Expand All @@ -143,14 +143,14 @@ def _get_used_and_obj(
raise PathMissingError(
self.def_path, self.def_repo[self.PARAM_URL]
) from exc
staging = copy(staging)
staging.read_only = True
object_store = copy(object_store)
object_store.read_only = True

self._staged_objs[rev] = staged_obj
used_obj_ids[staging].add(staged_obj.hash_info)
if isinstance(staged_obj, Tree):
used_obj_ids[staging].update(oid for _, _, oid in staged_obj)
return used_obj_ids, staged_obj
self._objs[rev] = obj
used_obj_ids[object_store].add(obj.hash_info)
if isinstance(obj, Tree):
used_obj_ids[object_store].update(oid for _, _, oid in obj)
return used_obj_ids, obj

def _check_circular_import(self, odb, obj_ids):
from dvc.exceptions import CircularImportError
Expand Down Expand Up @@ -190,8 +190,8 @@ def iter_objs():
def get_obj(self, filter_info=None, **kwargs):
locked = kwargs.get("locked", True)
rev = self._get_rev(locked=locked)
if rev in self._staged_objs:
return self._staged_objs[rev]
if rev in self._objs:
return self._objs[rev]
_, obj = self._get_used_and_obj(
obj_only=True, filter_info=filter_info, **kwargs
)
Expand Down
14 changes: 7 additions & 7 deletions dvc/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
from dvc_data import Tree
from dvc_data import check as ocheck
from dvc_data import load as oload
from dvc_data.build import build
from dvc_data.checkout import checkout
from dvc_data.hashfile.hash_info import HashInfo
from dvc_data.hashfile.istextfile import istextfile
from dvc_data.hashfile.meta import Meta
from dvc_data.stage import stage as ostage
from dvc_data.transfer import transfer as otransfer
from dvc_objects.errors import ObjectFormatError

Expand Down Expand Up @@ -427,7 +427,7 @@ def get_hash(self):
else:
odb = self.repo.odb.local
name = self.fs.PARAM_CHECKSUM
_, _, obj = ostage(
_, _, obj = build(
odb,
self.fs_path,
self.fs,
Expand Down Expand Up @@ -549,7 +549,7 @@ def save(self):
self.verify_metric()

if not self.use_cache:
_, self.meta, obj = ostage(
_, self.meta, obj = build(
self.repo.odb.local,
self.fs_path,
self.fs,
Expand All @@ -566,7 +566,7 @@ def save(self):

assert not self.IS_DEPENDENCY

_, self.meta, self.obj = ostage(
_, self.meta, self.obj = build(
self.odb,
self.fs_path,
self.fs,
Expand Down Expand Up @@ -608,7 +608,7 @@ def commit(self, filter_info=None):
if granular:
obj = self._commit_granular_dir(filter_info)
else:
staging, _, obj = ostage(
staging, _, obj = build(
self.odb,
filter_info or self.fs_path,
self.fs,
Expand Down Expand Up @@ -637,7 +637,7 @@ def _commit_granular_dir(self, filter_info):
prefix = self.fs.path.parts(
self.fs.path.relpath(filter_info, self.fs_path)
)
staging, _, save_obj = ostage(
staging, _, save_obj = build(
self.odb,
self.fs_path,
self.fs,
Expand Down Expand Up @@ -843,7 +843,7 @@ def transfer(

upload = not (update and from_fs.isdir(from_info))
jobs = jobs or min((from_fs.jobs, odb.fs.jobs))
staging, self.meta, obj = ostage(
staging, self.meta, obj = build(
odb,
from_info,
from_fs,
Expand Down
4 changes: 2 additions & 2 deletions dvc/repo/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def _paths_checksums(repo, targets):

def _output_paths(repo, targets):
from dvc.fs import LocalFileSystem
from dvc_data.stage import stage as ostage
from dvc_data.build import build

on_working_fs = isinstance(repo.fs, LocalFileSystem)

Expand All @@ -139,7 +139,7 @@ def _to_path(output):
)

if on_working_fs:
_, _, obj = ostage(
_, _, obj = build(
repo.odb.local,
output.fs_path,
repo.odb.local.fs,
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ install_requires =
scmrepo==0.0.25
dvc-render==0.0.6
dvclive>=0.7.3
dvc-data==0.0.19
dvc-data==0.0.20

[options.extras_require]
all =
Expand Down
2 changes: 1 addition & 1 deletion tests/func/test_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ def test(self):

def test_should_collect_dir_cache_only_once(mocker, tmp_dir, dvc):
tmp_dir.gen({"data/data": "foo"})
counter = mocker.spy(dvc_data.stage, "_stage_tree")
counter = mocker.spy(dvc_data.build, "_build_tree")
ret = main(["add", "data"])
assert ret == 0
assert counter.mock.call_count == 3
Expand Down
4 changes: 2 additions & 2 deletions tests/func/test_external_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from dvc.testing.tmp_dir import make_subrepo
from dvc.utils import relpath
from dvc.utils.fs import makedirs, remove
from dvc_data.stage import stage
from dvc_data.build import build
from dvc_data.transfer import transfer


Expand Down Expand Up @@ -202,7 +202,7 @@ def test_subrepos_are_ignored(tmp_dir, erepo_dir):
remove(cache_dir)
makedirs(cache_dir)

staging, _, obj = stage(
staging, _, obj = build(
repo.odb.local,
"dir",
repo.dvcfs,
Expand Down
2 changes: 1 addition & 1 deletion tests/func/test_ignore.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from dvc.repo import Repo
from dvc.testing.tmp_dir import TmpDir
from dvc.types import List
from dvc_data.build import IgnoreInCollectedDirError
from dvc_data.hashfile.utils import get_mtime_and_size
from dvc_data.stage import IgnoreInCollectedDirError


def _to_pattern_info_list(str_list: List):
Expand Down
12 changes: 6 additions & 6 deletions tests/func/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ def test_upper_case_remote(tmp_dir, dvc, local_cloud):


def test_dir_hash_should_be_key_order_agnostic(tmp_dir, dvc):
from dvc_data.build import build
from dvc_data.objects.tree import Tree
from dvc_data.stage import stage

tmp_dir.gen({"data": {"1": "1 content", "2": "2 content"}})

Expand All @@ -150,19 +150,19 @@ def test_dir_hash_should_be_key_order_agnostic(tmp_dir, dvc):
[{"relpath": "1", "md5": "1"}, {"relpath": "2", "md5": "2"}]
)
tree.digest()
with patch("dvc_data.stage._stage_tree", return_value=(None, tree)):
_, _, obj = stage(dvc.odb.local, path, dvc.odb.local.fs, "md5")
with patch("dvc_data.build._build_tree", return_value=(None, tree)):
_, _, obj = build(dvc.odb.local, path, dvc.odb.local.fs, "md5")
hash1 = obj.hash_info

# remove the raw dir obj to force building the tree on the next stage call
# remove the raw dir obj to force building the tree on the next build call
dvc.odb.local.fs.remove(dvc.odb.local.oid_to_path(hash1.as_raw().value))

tree = Tree.from_list(
[{"md5": "1", "relpath": "1"}, {"md5": "2", "relpath": "2"}]
)
tree.digest()
with patch("dvc_data.stage._stage_tree", return_value=(None, tree)):
_, _, obj = stage(dvc.odb.local, path, dvc.odb.local.fs, "md5")
with patch("dvc_data.build._build_tree", return_value=(None, tree)):
_, _, obj = build(dvc.odb.local, path, dvc.odb.local.fs, "md5")
hash2 = obj.hash_info

assert hash1 == hash2
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/cli/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from funcy import raiser

from dvc.cli import main
from dvc_data.build import IgnoreInCollectedDirError
from dvc_data.hashfile.cache import DiskError
from dvc_data.stage import IgnoreInCollectedDirError
from dvc_objects.fs.base import FileSystem, RemoteMissingDepsError


Expand Down
8 changes: 4 additions & 4 deletions tests/unit/data/db/test_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ def test_set_exec_ignore_errors(tmp_dir, dvc, mocker, err):

def test_staging_file(tmp_dir, dvc):
from dvc_data import check
from dvc_data.stage import stage
from dvc_data.build import build
from dvc_data.transfer import transfer

tmp_dir.gen("foo", "foo")
fs = LocalFileSystem()

local_odb = dvc.odb.local
staging_odb, _, obj = stage(
staging_odb, _, obj = build(
local_odb, (tmp_dir / "foo").fs_path, fs, "md5"
)

Expand All @@ -114,14 +114,14 @@ def test_staging_file(tmp_dir, dvc):

def test_staging_dir(tmp_dir, dvc):
from dvc_data import check
from dvc_data.stage import stage
from dvc_data.build import build
from dvc_data.transfer import transfer

tmp_dir.gen({"dir": {"foo": "foo", "bar": "bar"}})
fs = LocalFileSystem()
local_odb = dvc.odb.local

staging_odb, _, obj = stage(
staging_odb, _, obj = build(
local_odb, (tmp_dir / "dir").fs_path, fs, "md5"
)

Expand Down
10 changes: 5 additions & 5 deletions tests/unit/fs/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from dvc.config import NoRemoteError
from dvc.fs.data import DataFileSystem
from dvc.utils.fs import remove
from dvc_data.build import build
from dvc_data.hashfile.hash_info import HashInfo
from dvc_data.stage import stage


@pytest.mark.parametrize(
Expand Down Expand Up @@ -243,13 +243,13 @@ def test_get_hash_granular(tmp_dir, dvc):
fs = DataFileSystem(repo=dvc)
subdir = "dir/subdir"
assert fs.info(subdir).get("md5") is None
_, _, obj = stage(dvc.odb.local, subdir, fs, "md5", dry_run=True)
_, _, obj = build(dvc.odb.local, subdir, fs, "md5", dry_run=True)
assert obj.hash_info == HashInfo(
"md5", "af314506f1622d107e0ed3f14ec1a3b5.dir"
)
data = posixpath.join(subdir, "data")
assert fs.info(data)["md5"] == "8d777f385d3dfec8815d20f7496026dc"
_, _, obj = stage(dvc.odb.local, data, fs, "md5", dry_run=True)
_, _, obj = build(dvc.odb.local, data, fs, "md5", dry_run=True)
assert obj.hash_info == HashInfo("md5", "8d777f385d3dfec8815d20f7496026dc")


Expand All @@ -260,7 +260,7 @@ def test_get_hash_dirty_file(tmp_dir, dvc):
fs = DataFileSystem(repo=dvc)
expected = "8c7dd922ad47494fc02c388e12c00eac"
assert fs.info("file").get("md5") == expected
_, _, obj = stage(dvc.odb.local, "file", fs, "md5", dry_run=True)
_, _, obj = build(dvc.odb.local, "file", fs, "md5", dry_run=True)
assert obj.hash_info == HashInfo("md5", expected)


Expand All @@ -271,5 +271,5 @@ def test_get_hash_dirty_dir(tmp_dir, dvc):
fs = DataFileSystem(repo=dvc)
expected = "5ea40360f5b4ec688df672a4db9c17d1.dir"
assert fs.info("dir").get("md5") == expected
_, _, obj = stage(dvc.odb.local, "dir", fs, "md5", dry_run=True)
_, _, obj = build(dvc.odb.local, "dir", fs, "md5", dry_run=True)
assert obj.hash_info == HashInfo("md5", expected)
Loading

0 comments on commit 8b3020a

Please sign in to comment.