mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-19 15:28:28 +01:00
Initial simple separation to get the process of extracting dvc-objects and dvc-data packages out of dvc. dvc-objects is for: * defining base Object (aka HashFile) and ObjectDB * providing tools to work with those objects (check/transfer/etc) * etc dvc-data is for: * defining higher level objects (e.g. Tree) * bulding objects from the workspace (aka staging) * projecting objects back into the workspace (aka checkout) * comparing Tree objects (aka diff) * defining misc object databases (e.g LocalObjectDB) * higher-level transfer (e.g. with Tree indexes) * etc For example, the objects we use in run-cache are based on dvc-objects and not on dvc-data, as they have absolutely nothing to do with data management. There are still some mixups in the code that will be addressed in the followups.
34 lines
814 B
Python
34 lines
814 B
Python
import logging
|
|
from typing import TYPE_CHECKING, Iterator, Union
|
|
|
|
from .tree import Tree
|
|
|
|
if TYPE_CHECKING:
|
|
from dvc.hash_info import HashInfo
|
|
from dvc.objects.db import ObjectDB
|
|
from dvc.objects.file import HashFile
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
def check(odb: "ObjectDB", obj: "HashFile", **kwargs):
|
|
if isinstance(obj, Tree):
|
|
for _, _, oid in obj:
|
|
odb.check(oid, **kwargs)
|
|
|
|
odb.check(obj.hash_info, **kwargs)
|
|
|
|
|
|
def load(odb: "ObjectDB", hash_info: "HashInfo") -> "HashFile":
|
|
if hash_info.isdir:
|
|
return Tree.load(odb, hash_info)
|
|
return odb.get(hash_info)
|
|
|
|
|
|
def iterobjs(
|
|
obj: Union["Tree", "HashFile"]
|
|
) -> Iterator[Union["Tree", "HashFile"]]:
|
|
if isinstance(obj, Tree):
|
|
yield from (entry_obj for _, entry_obj in obj)
|
|
yield obj
|