mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-01 23:08:43 +01:00
odb: treat external repo dependencies as objects (#6109)
* objects: add ExternalRepoFile object type * RepoDependency: implement get_obj (use ExternalRepoFile) * drop distinction between used external and used objects * update tests * remove unneeded fetch from ExternalRepoFile * wrap erepo errors as an object error * update cloud/remote functions for new used_objs behavior * fix update() rev/locked behavior * update import tests * remove ExternalRepoFile * move get_obj and get_used_objs implementations back into repo dependency * return objects plus associated ODB (remote) in get_used_objs * odb: add tmp_dir field and support creating Remote from an odb * return dict mapping odb -> objects in get_used_objs * use dummy git odb for git imports * fetch: support pulling from specific odb * update cloud funcs for get_used_objs usage * update tests for used_objs behavior * use fetch in dep.download * catch circular imports from local fs repos * add tests for chained and circular imports * move tmp_dir into odb config * update return docstring for repo.used_objs
This commit is contained in:
@@ -44,26 +44,24 @@ def test_find_outs_by_path_does_graph_checks(tmp_dir, dvc):
|
||||
"path",
|
||||
[os.path.join("dir", "subdir", "file"), os.path.join("dir", "subdir")],
|
||||
)
|
||||
def test_used_cache(tmp_dir, dvc, path):
|
||||
def test_used_objs(tmp_dir, dvc, path):
|
||||
from dvc.objects.tree import Tree
|
||||
|
||||
tmp_dir.dvc_gen({"dir": {"subdir": {"file": "file"}, "other": "other"}})
|
||||
|
||||
expected_objs = {
|
||||
expected = {
|
||||
HashInfo("md5", "70922d6bf66eb073053a82f77d58c536.dir"),
|
||||
HashInfo("md5", "8c7dd922ad47494fc02c388e12c00eac"),
|
||||
}
|
||||
expected_external = {}
|
||||
|
||||
objs, external = dvc.used_cache([path])
|
||||
used = set()
|
||||
for obj in objs:
|
||||
used.add(obj.hash_info)
|
||||
if isinstance(obj, Tree):
|
||||
used.update(entry_obj.hash_info for _, entry_obj in obj)
|
||||
for _, objs in dvc.used_objs([path]).items():
|
||||
for obj in objs:
|
||||
used.add(obj.hash_info)
|
||||
if isinstance(obj, Tree):
|
||||
used.update(entry_obj.hash_info for _, entry_obj in obj)
|
||||
|
||||
assert used == expected_objs
|
||||
assert external == expected_external
|
||||
assert used == expected
|
||||
|
||||
|
||||
def test_locked(mocker):
|
||||
|
||||
Reference in New Issue
Block a user