Skip to content

Commit

Permalink
index: add cache
Browse files Browse the repository at this point in the history
  • Loading branch information
efiop committed May 7, 2023
1 parent 6b6084a commit 734ade3
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion dvc/repo/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def _load_data_from_outs(index, prefix, outs):
def _load_storage_from_out(storage_map, key, out):
from dvc.config import NoRemoteError
from dvc_data.index import FileStorage, ObjectStorage
from fsspec.utils import tokenize

if out.odb:
storage_map.add_data(ObjectStorage(key, out.odb))
Expand All @@ -156,14 +157,32 @@ def _load_storage_from_out(storage_map, key, out):
index=remote.index,
)
)

token = f"{out.fs.protocol}-{tokenize(out.fs_path)}"
storage_map.add_cache(
FileStorage(
key=key,
fs=out.cache.fs,
path=out.cache.fs.path.join(out.cache.path, "fs", token),
)
)
else:
storage_map.add_remote(ObjectStorage(key, remote.odb, index=remote.index))
except NoRemoteError:
pass

if out.stage.is_import:
dep = out.stage.deps[0]
storage_map.add_data(FileStorage(key, dep.fs, dep.fs_path))
storage_map.add_remote(FileStorage(key, dep.fs, dep.fs_path))

token = f"{dep.fs.protocol}-{tokenize(dep.fs_path)}"
storage_map.add_cache(
FileStorage(
key=key,
fs=out.cache.fs,
path=out.cache.fs.path.join(out.cache.path, "fs", token),
)
)


class Index:
Expand Down

0 comments on commit 734ade3

Please sign in to comment.