diff --git a/dvc/output.py b/dvc/output.py index 304444169..8eb6b4a5d 100644 --- a/dvc/output.py +++ b/dvc/output.py @@ -29,7 +29,6 @@ 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.hashfile.transfer import transfer as otransfer -from dvc_data.index import DataIndexEntry from dvc_objects.errors import ObjectFormatError from .annotations import ANNOTATION_FIELDS, ANNOTATION_SCHEMA, Annotation @@ -39,6 +38,7 @@ from .utils import relpath from .utils.fs import path_isin if TYPE_CHECKING: + from dvc_data.hashfile.db import HashFileDB from dvc_data.hashfile.obj import HashFile from dvc_data.index import DataIndexKey from dvc_objects.db import ObjectDB @@ -394,6 +394,7 @@ class Output: self.fs_path = self._parse_path(self.fs, fs_path) self.obj: Optional["HashFile"] = None + self.odb: Optional["HashFileDB"] = None self.remote = remote if self.fs.version_aware: @@ -415,8 +416,13 @@ class Output: def _compute_meta_hash_info_from_files(self) -> None: if self.files: + from dvc_data.hashfile.db import HashFileDB + tree = Tree.from_list(self.files, hash_name=self.hash_name) - tree.digest() + tree.digest(with_meta=True) + self.odb = HashFileDB(tree.fs, tree.path + ".odb") + self.odb.add(tree.path, tree.fs, tree.hash_info.value) + self.hash_info = tree.hash_info self.meta.isdir = True self.meta.nfiles = len(self.files) @@ -563,26 +569,6 @@ class Output: key = self.fs.path.parts(no_drive)[1:] return workspace, key - def get_entry(self) -> "DataIndexEntry": - if self.files and not self.obj: - self.obj = self.get_obj() - - entry = DataIndexEntry( - meta=self.meta, - obj=self.obj, - hash_info=self.hash_info, - ) - if self.stage.is_import and not self.stage.is_repo_import: - dep = self.stage.deps[0] - entry.meta = dep.meta - if not entry.obj: - if not dep.obj and dep.files: - dep.obj = dep.get_obj() - entry.obj = dep.obj - if not entry.hash_info and dep.obj: - entry.hash_info = dep.obj.hash_info - return entry - def changed_checksum(self): return self.hash_info != self.get_hash() diff --git a/dvc/repo/data.py b/dvc/repo/data.py index 57d89ddc9..629f64c0b 100644 --- a/dvc/repo/data.py +++ b/dvc/repo/data.py @@ -94,7 +94,7 @@ def _diff( with_missing and change.old and change.old.hash_info - and not old.storage_map[change.key].odb.exists(change.old.hash_info.value) + and not old.storage_map[change.key].cache.exists(change.old.hash_info.value) ): # NOTE: emulating previous behaviour _add_change("not_in_cache", change) diff --git a/dvc/repo/index.py b/dvc/repo/index.py index 2d2167772..a97c99367 100644 --- a/dvc/repo/index.py +++ b/dvc/repo/index.py @@ -286,7 +286,7 @@ class Index: from collections import defaultdict from dvc.config import NoRemoteError - from dvc_data.index import DataIndex, Storage + from dvc_data.index import DataIndex, DataIndexEntry, Storage by_workspace: dict = defaultdict(DataIndex) @@ -300,11 +300,13 @@ class Index: workspace, key = out.index_key data_index = by_workspace[workspace] - entry = out.get_entry() - entry.key = key - data_index.add(entry) + entry = DataIndexEntry( + key=key, + meta=out.meta, + hash_info=out.hash_info, + ) - storage = Storage(odb=out.cache) + storage = Storage(odb=out.odb, cache=out.cache) try: storage.remote = self.repo.cloud.get_remote_odb(out.remote) except NoRemoteError: @@ -312,9 +314,15 @@ class Index: if out.stage.is_import and not out.stage.is_repo_import: dep = out.stage.deps[0] + + entry.meta = dep.meta + entry.hash_info = dep.hash_info + + storage.odb = dep.odb storage.fs = dep.fs storage.path = dep.fs_path + data_index.add(entry) data_index.storage_map[key] = storage return dict(by_workspace) diff --git a/pyproject.toml b/pyproject.toml index 6f935df6e..5b6d42526 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,7 +53,7 @@ dependencies = [ "dvc-render==0.1.1", "dvc-task==0.1.11", "dvclive>=1.2.2", - "dvc-data==0.38.4", + "dvc-data==0.39.3", "dvc-http", "hydra-core>=1.1.0", "iterative-telemetry==0.0.7",