dvc.objects: move hash_info, state and meta into dvc.objects

This commit is contained in:
Saugat Pachhai (सौगात)
2022-05-11 17:35:48 +03:00
committed by Ruslan Kuprieiev
parent 7a1f133f29
commit 14c9348f93
42 changed files with 52 additions and 51 deletions
+1 -1
View File
@@ -4,9 +4,9 @@ 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
from dvc.objects.hash_info import HashInfo
logger = logging.getLogger(__name__)
+1 -1
View File
@@ -6,9 +6,9 @@ from functools import partial
from funcy import cached_property
from shortuuid import uuid
from dvc.hash_info import HashInfo
from dvc.objects.db import ObjectDB, noop, wrap_iter
from dvc.objects.errors import ObjectFormatError
from dvc.objects.hash_info import HashInfo
from dvc.utils import relpath
from dvc.utils.fs import copyfile, remove, umask, walk_files
+1 -1
View File
@@ -11,7 +11,7 @@ from ..reference import ReferenceHashFile
if TYPE_CHECKING:
from dvc.fs._callback import FsspecCallback
from dvc.fs.base import AnyFSPath, FileSystem
from dvc.hash_info import HashInfo
from dvc.objects.hash_info import HashInfo
logger = logging.getLogger(__name__)
+1 -1
View File
@@ -2,8 +2,8 @@ from dataclasses import dataclass, field
from typing import TYPE_CHECKING, List, Optional, Tuple
if TYPE_CHECKING:
from dvc.hash_info import HashInfo
from dvc.objects.file import HashFile
from dvc.objects.hash_info import HashInfo
ADD = "add"
MODIFY = "modify"
+1 -1
View File
@@ -18,7 +18,7 @@ def gc(odb, used, jobs=None, cache_odb=None, shallow=True):
)
def _is_dir_hash(_hash):
from dvc.hash_info import HASH_DIR_SUFFIX
from dvc.objects.hash_info import HASH_DIR_SUFFIX
return _hash.endswith(HASH_DIR_SUFFIX)
+1 -1
View File
@@ -9,8 +9,8 @@ from dvc.objects.file import HashFile
if TYPE_CHECKING:
from dvc.fs.base import AnyFSPath, FileSystem
from dvc.hash_info import HashInfo
from dvc.objects.db import ObjectDB
from dvc.objects.hash_info import HashInfo
logger = logging.getLogger(__name__)
+2 -2
View File
@@ -6,14 +6,14 @@ from functools import partial
from typing import TYPE_CHECKING, Dict, Optional, Tuple
from dvc.exceptions import DvcIgnoreInCollectedDirError
from dvc.hash_info import HashInfo
from dvc.ignore import DvcIgnore
from dvc.objects.file import HashFile
from dvc.objects.hash_info import HashInfo
from dvc.objects.meta import Meta
from dvc.progress import Tqdm
from dvc.utils import file_md5, is_exec
from .db.reference import ReferenceObjectDB
from .meta import Meta
if TYPE_CHECKING:
from dvc.fs.base import AnyFSPath, FileSystem
+1 -1
View File
@@ -1,7 +1,7 @@
import logging
from typing import TYPE_CHECKING, Dict, Iterable, NamedTuple, Optional, Set
from dvc.hash_info import HashInfo
from dvc.objects.hash_info import HashInfo
from dvc.scheme import Schemes
from .tree import Tree
+1 -1
View File
@@ -9,8 +9,8 @@ from dvc.progress import Tqdm
from dvc.utils.threadpool import ThreadPoolExecutor
if TYPE_CHECKING:
from dvc.hash_info import HashInfo
from dvc.objects.db import ObjectDB
from dvc.objects.hash_info import HashInfo
from .db.index import ObjectDBIndexBase
from .tree import Tree
+3 -4
View File
@@ -11,10 +11,9 @@ from dvc.objects.file import HashFile
from .stage import get_file_hash
if TYPE_CHECKING:
from dvc.hash_info import HashInfo
from dvc.objects.db import ObjectDB
from .meta import Meta
from dvc.objects.hash_info import HashInfo
from dvc.objects.meta import Meta
logger = logging.getLogger(__name__)
@@ -129,7 +128,7 @@ class Tree(HashFile):
@classmethod
def from_list(cls, lst):
from dvc.hash_info import HashInfo
from dvc.objects.hash_info import HashInfo
tree = cls(None, None, None)
for _entry in lst:
+1 -1
View File
@@ -6,8 +6,8 @@ from typing import TYPE_CHECKING, Iterable, Optional
from dvc.data.db import get_index
if TYPE_CHECKING:
from dvc.hash_info import HashInfo
from dvc.objects.db import ObjectDB
from dvc.objects.hash_info import HashInfo
logger = logging.getLogger(__name__)
+1 -1
View File
@@ -8,7 +8,7 @@ import dpath.util
from voluptuous import Any
from dvc.exceptions import DvcException
from dvc.hash_info import HashInfo
from dvc.objects.hash_info import HashInfo
from dvc.utils.serialize import LOADERS, ParseError
from .base import Dependency
+1 -1
View File
@@ -8,9 +8,9 @@ from voluptuous import Required
from .base import Dependency
if TYPE_CHECKING:
from dvc.hash_info import HashInfo
from dvc.objects.db import ObjectDB
from dvc.objects.file import HashFile
from dvc.objects.hash_info import HashInfo
class RepoDependency(Dependency):
+1 -1
View File
@@ -117,7 +117,7 @@ class _DvcFileSystem(AbstractFileSystem): # pylint:disable=abstract-method
return bool(info.get("outs") if recurse else info.get("isout"))
def info(self, path, **kwargs):
from dvc.data.meta import Meta
from dvc.objects.meta import Meta
key = self._get_key(path)
+3 -2
View File
@@ -14,7 +14,8 @@ if TYPE_CHECKING:
from dvc.fs._callback import FsspecCallback
from dvc.fs.base import AnyFSPath, FileSystem
from dvc.hash_info import HashInfo
from .hash_info import HashInfo
logger = logging.getLogger(__name__)
@@ -36,7 +37,7 @@ class ObjectDB:
CACHE_MODE: Optional[int] = None
def __init__(self, fs: "FileSystem", path: str, **config):
from dvc.state import StateNoop
from .state import StateNoop
self.fs = fs
self.fs_path = path
+1 -1
View File
@@ -5,9 +5,9 @@ from typing import TYPE_CHECKING, Optional
if TYPE_CHECKING:
from dvc.fs.base import AnyFSPath, FileSystem
from dvc.hash_info import HashInfo
from .db import ObjectDB
from .hash_info import HashInfo
logger = logging.getLogger(__name__)
+3 -2
View File
@@ -5,11 +5,12 @@ import os
from abc import ABC, abstractmethod
from dvc.fs.local import LocalFileSystem
from dvc.hash_info import HashInfo
from dvc.utils import relpath
from dvc.utils.decorators import with_diskcache
from dvc.utils.fs import get_inode, get_mtime_and_size, remove
from .hash_info import HashInfo
logger = logging.getLogger(__name__)
@@ -106,7 +107,7 @@ class State(StateBase): # pylint: disable=too-many-instance-attributes
HashInfo or None: hash for the specified path info or None if it
doesn't exist in the state database.
"""
from .data.meta import Meta
from .meta import Meta
if not isinstance(fs, LocalFileSystem):
return None, None
+2 -2
View File
@@ -15,11 +15,12 @@ from dvc.exceptions import (
MergeError,
RemoteCacheRequiredError,
)
from dvc.objects.hash_info import HashInfo
from dvc.objects.meta import Meta
from .data import check as ocheck
from .data import load as oload
from .data.checkout import checkout
from .data.meta import Meta
from .data.stage import stage as ostage
from .data.transfer import transfer as otransfer
from .data.tree import Tree
@@ -28,7 +29,6 @@ from .fs.base import RemoteMissingDepsError
from .fs.hdfs import HDFSFileSystem
from .fs.local import LocalFileSystem
from .fs.s3 import S3FileSystem
from .hash_info import HashInfo
from .istextfile import istextfile
from .objects.errors import ObjectFormatError
from .scheme import Schemes
+1 -1
View File
@@ -155,13 +155,13 @@ class Repo:
from dvc.fs.git import GitFileSystem
from dvc.fs.local import localfs
from dvc.lock import LockNoop, make_lock
from dvc.objects.state import State, StateNoop
from dvc.repo.metrics import Metrics
from dvc.repo.params import Params
from dvc.repo.plots import Plots
from dvc.repo.stage import StageLoad
from dvc.scm import SCM
from dvc.stage.cache import StageCache
from dvc.state import State, StateNoop
self.url = url
self._fs_conf = {"repo_factory": repo_factory}
+1 -1
View File
@@ -22,8 +22,8 @@ if TYPE_CHECKING:
from dvc.data.tree import Tree
from dvc.dependency import Dependency, ParamsDependency
from dvc.fs.base import FileSystem
from dvc.hash_info import HashInfo
from dvc.objects.db import ObjectDB
from dvc.objects.hash_info import HashInfo
from dvc.output import Output
from dvc.repo.stage import StageLoad
from dvc.stage import Stage
+1 -1
View File
@@ -3,7 +3,7 @@ from collections.abc import Mapping
from voluptuous import Any, Optional, Required, Schema
from dvc import dependency, output
from dvc.data.meta import Meta
from dvc.objects.meta import Meta
from dvc.output import CHECKSUMS_SCHEMA, Output
from dvc.parsing import DO_KWD, FOREACH_KWD, VARS_KWD
from dvc.parsing.versions import SCHEMA_KWD, lockfile_version_schema
+1 -1
View File
@@ -36,8 +36,8 @@ from .utils import (
if TYPE_CHECKING:
from dvc.dvcfile import DVCFile
from dvc.hash_info import HashInfo
from dvc.objects.db.base import ObjectDB
from dvc.objects.hash_info import HashInfo
logger = logging.getLogger(__name__)
# Disallow all punctuation characters except hyphen and underscore
+1 -1
View File
@@ -23,7 +23,7 @@ class RunCacheNotFoundError(DvcException):
def _get_cache_hash(cache, key=False):
from dvc.data.meta import Meta
from dvc.objects.meta import Meta
if key:
cache["outs"] = [out["path"] for out in cache.get("outs", [])]
+2 -2
View File
@@ -6,8 +6,8 @@ from itertools import chain
from funcy import cached_property, get_in, lcat, once, project
from dvc import dependency, output
from dvc.data.meta import Meta
from dvc.hash_info import HashInfo
from dvc.objects.hash_info import HashInfo
from dvc.objects.meta import Meta
from dvc.parsing import FOREACH_KWD, JOIN, DataResolver, EntryNotFound
from dvc.parsing.versions import LOCKFILE_VERSION
+1 -1
View File
@@ -4,8 +4,8 @@ from typing import TYPE_CHECKING, Union
from funcy import concat, first, lsplit, rpartial, without
from dvc.data.meta import Meta
from dvc.exceptions import InvalidArgumentError
from dvc.objects.meta import Meta
from .exceptions import (
MissingDataSource,
+1 -1
View File
@@ -3,8 +3,8 @@ import io
from funcy import cached_property
from dvc.hash_info import HashInfo
from dvc.istextfile import DEFAULT_CHUNK_SIZE, istextblock
from dvc.objects.hash_info import HashInfo
from dvc.utils import dos2unix
+1 -1
View File
@@ -22,7 +22,7 @@ from dvc.exceptions import (
RecursiveAddingWhileUsingFilename,
)
from dvc.fs.local import LocalFileSystem
from dvc.hash_info import HashInfo
from dvc.objects.hash_info import HashInfo
from dvc.output import (
OutputAlreadyTrackedError,
OutputDoesNotExistError,
+1 -1
View File
@@ -6,7 +6,7 @@ from operator import itemgetter
import pytest
from dvc.dvcfile import PIPELINE_LOCK, Lockfile
from dvc.hash_info import HashInfo
from dvc.objects.hash_info import HashInfo
from dvc.stage.utils import split_params_deps
from dvc.utils.fs import remove
from dvc.utils.serialize import dumps_yaml, parse_yaml_for_update
+1 -1
View File
@@ -6,8 +6,8 @@ import pytest
from dvc.cli import main
from dvc.data.db import ODBManager
from dvc.hash_info import HashInfo
from dvc.objects.errors import ObjectFormatError
from dvc.objects.hash_info import HashInfo
from dvc.utils import relpath
+1 -1
View File
@@ -258,7 +258,7 @@ def get_index(dvc, rev):
@pytest.mark.parametrize("rev", ["workspace", "HEAD"])
def test_used_objs(tmp_dir, scm, dvc, run_copy, rev):
from dvc.hash_info import HashInfo
from dvc.objects.hash_info import HashInfo
dvc.config["core"]["autostage"] = True
tmp_dir.dvc_gen({"dir": {"subdir": {"file": "file"}}, "foo": "foo"})
+1 -1
View File
@@ -817,7 +817,7 @@ class TestReproAllPipelines(SingleStageRun, TestDvc):
),
]
from dvc.state import StateNoop
from dvc.objects.state import StateNoop
self.dvc.state = StateNoop()
+2 -2
View File
@@ -1,9 +1,9 @@
import os
import re
from dvc.hash_info import HashInfo
from dvc.objects.hash_info import HashInfo
from dvc.objects.state import State
from dvc.repo import Repo
from dvc.state import State
from dvc.utils import file_md5
+1 -1
View File
@@ -6,7 +6,7 @@ import pytest
from dvc.config import NoRemoteError
from dvc.data.stage import stage
from dvc.fs.dvc import DvcFileSystem
from dvc.hash_info import HashInfo
from dvc.objects.hash_info import HashInfo
from dvc.utils.fs import remove
+1 -1
View File
@@ -7,7 +7,7 @@ import pytest
from dvc.data.stage import stage
from dvc.fs.repo import RepoFileSystem
from dvc.hash_info import HashInfo
from dvc.objects.hash_info import HashInfo
from tests.utils import clean_staging
+1 -1
View File
@@ -5,7 +5,7 @@ import pytest
from dvc.data.db.local import LocalObjectDB
from dvc.fs.local import LocalFileSystem
from dvc.hash_info import HashInfo
from dvc.objects.hash_info import HashInfo
def test_status_download_optimization(mocker, dvc):
+2 -2
View File
@@ -2,9 +2,9 @@ from operator import itemgetter
import pytest
from dvc.data.meta import Meta
from dvc.data.tree import Tree, _merge
from dvc.hash_info import HashInfo
from dvc.objects.hash_info import HashInfo
from dvc.objects.meta import Meta
@pytest.mark.parametrize(
+2 -2
View File
@@ -1,8 +1,8 @@
import os
from unittest.mock import patch
from dvc.data.meta import Meta
from dvc.hash_info import HashInfo
from dvc.objects.hash_info import HashInfo
from dvc.objects.meta import Meta
from dvc.output import Output
from dvc.stage import Stage
from dvc.utils import relpath
+1 -1
View File
@@ -4,7 +4,7 @@ import shutil
import pytest
from dvc.exceptions import OutputDuplicationError
from dvc.hash_info import HashInfo
from dvc.objects.hash_info import HashInfo
from dvc.repo import NotDvcRepoError, Repo, locked
@@ -5,7 +5,7 @@ from itertools import chain
import pytest
from dvc.dvcfile import PIPELINE_FILE, Dvcfile
from dvc.hash_info import HashInfo
from dvc.objects.hash_info import HashInfo
from dvc.stage import PipelineStage, create_stage
from dvc.stage.loader import StageLoader
from dvc.stage.serialize import split_params_deps
@@ -4,7 +4,7 @@ import pytest
from voluptuous import Schema as _Schema
from dvc.dvcfile import PIPELINE_FILE
from dvc.hash_info import HashInfo
from dvc.objects.hash_info import HashInfo
from dvc.schema import LOCK_FILE_STAGE_SCHEMA, LOCKFILE_STAGES_SCHEMA
from dvc.stage import PipelineStage, create_stage
from dvc.stage.serialize import DEFAULT_PARAMS_FILE, to_lockfile