Skip to content

Commit

Permalink
ololo
Browse files Browse the repository at this point in the history
  • Loading branch information
efiop committed Feb 15, 2024
1 parent 6efd699 commit c49afb1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
22 changes: 14 additions & 8 deletions dvc/repo/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def is_out_or_ignored(root, directory):
dirs[:] = [d for d in dirs if not is_out_or_ignored(root, d)]


def _load_data_from_tree(index, prefix, ws, key, tree):
def _load_data_from_tree(index, prefix, ws, key, tree, hash_name):
from dvc_data.index import DataIndexEntry, Meta

parents = set()
Expand All @@ -117,7 +117,7 @@ def _load_data_from_tree(index, prefix, ws, key, tree):
index[(*prefix, ws, *fkey)] = DataIndexEntry(
key=fkey,
meta=ometa,
hash_info=ohi,
hash_info=ohi if (ohi and ohi.name == hash_name) else None,
)

for parent in parents:
Expand Down Expand Up @@ -151,7 +151,7 @@ def _load_data_from_outs(index, prefix, outs):
tree = out.get_obj()

if tree is not None:
_load_data_from_tree(index, prefix, ws, key, tree)
_load_data_from_tree(index, prefix, ws, key, tree, out.hash_name)

entry = DataIndexEntry(
key=key,
Expand Down Expand Up @@ -193,16 +193,22 @@ def _load_storage_from_import(storage_map, key, out):
return

dep = out.stage.deps[0]
if not out.hash_info and (
not dep.hash_info or dep.hash_info.name != storage_map[key].cache.odb.hash_name
):
# partial import
if not out.hash_info or dep.fs.version_aware:
if dep.meta and dep.meta.isdir:
meta_token = dep.hash_info.value
else:
meta_token = tokenize(dep.meta.to_dict())

fs_cache = out.repo.cache.fs_cache
storage_map.add_cache(
FileStorage(
key,
fs_cache.fs,
fs_cache.fs.join(fs_cache.path, dep.fs.protocol, tokenize(dep.fs_path)),
fs_cache.fs.join(
fs_cache.path,
dep.fs.protocol,
tokenize(dep.fs_path, meta_token),
),
)
)

Expand Down
12 changes: 6 additions & 6 deletions dvc/testing/workspace_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ def test_import_file(self, tmp_dir, dvc, remote_version_aware):
assert (tmp_dir / "file").read_text() == "file"

(remote_version_aware / "file").write_text("modified")
assert dvc.status().get("file.dvc") == [
{"changed deps": {"remote://upstream/file": "update available"}},
]
assert dvc.status().get("file.dvc")[0]["changed deps"] == {
"remote://upstream/file": "update available"
}
dvc.update(str(tmp_dir / "file.dvc"))
assert (tmp_dir / "file").read_text() == "modified"
assert dvc.status() == {}
Expand Down Expand Up @@ -135,9 +135,9 @@ def test_import_dir(self, tmp_dir, dvc, remote_version_aware):

(remote_version_aware / "data_dir" / "subdir" / "file").write_text("modified")
(remote_version_aware / "data_dir" / "new_file").write_text("new")
assert dvc.status().get("data_dir.dvc") == [
{"changed deps": {"remote://upstream/data_dir": "modified"}},
]
assert dvc.status().get("data_dir.dvc")[0]["changed deps"] == {
"remote://upstream/data_dir": "modified"
}
dvc.update(str(tmp_dir / "data_dir.dvc"))
assert (tmp_dir / "data_dir" / "subdir" / "file").read_text() == "modified"
assert (tmp_dir / "data_dir" / "new_file").read_text() == "new"
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ dependencies = [
"configobj>=5.0.6",
"distro>=1.3",
"dpath<3,>=2.1.0",
"dvc-data>=3.10,<3.12",
#"dvc-data>=3.10,<3.12",
"dvc-data@git+https://github.com/efiop/dvc-data#egg=fetch-handle-md5",
"dvc-http>=2.29.0",
"dvc-render>=1.0.1,<2",
"dvc-studio-client>=0.19,<1",
Expand Down

0 comments on commit c49afb1

Please sign in to comment.