mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
parsing: make imports lazy (#5225)
* parsing: make imports lazy * Locally declare default params file
This commit is contained in:
@@ -5,7 +5,6 @@ from typing import TYPE_CHECKING, Any, Dict, NamedTuple, Union
|
||||
|
||||
from funcy import cached_property, collecting, first, isa, join, reraise
|
||||
|
||||
from dvc.dependency.param import ParamsDependency
|
||||
from dvc.exceptions import DvcException
|
||||
from dvc.parsing.interpolate import ParseError
|
||||
from dvc.path_info import PathInfo
|
||||
@@ -34,11 +33,11 @@ logger = logging.getLogger(__name__)
|
||||
STAGES_KWD = "stages"
|
||||
VARS_KWD = "vars"
|
||||
WDIR_KWD = "wdir"
|
||||
DEFAULT_PARAMS_FILE = ParamsDependency.DEFAULT_PARAMS_FILE
|
||||
PARAMS_KWD = "params"
|
||||
FOREACH_KWD = "foreach"
|
||||
DO_KWD = "do"
|
||||
|
||||
DEFAULT_PARAMS_FILE = "params.yaml"
|
||||
DEFAULT_SENTINEL = object()
|
||||
|
||||
JOIN = "@"
|
||||
|
||||
@@ -21,8 +21,6 @@ from dvc.parsing.interpolate import (
|
||||
)
|
||||
from dvc.path_info import PathInfo
|
||||
from dvc.utils import relpath
|
||||
from dvc.utils.humanize import join
|
||||
from dvc.utils.serialize import LOADERS
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
SeqOrMap = Union[Sequence, Mapping]
|
||||
@@ -34,6 +32,8 @@ class ContextError(DvcException):
|
||||
|
||||
class ReservedKeyError(ContextError):
|
||||
def __init__(self, keys, path=None):
|
||||
from dvc.utils.humanize import join
|
||||
|
||||
self.keys = keys
|
||||
self.path = path
|
||||
|
||||
@@ -347,6 +347,8 @@ class Context(CtxDict):
|
||||
|
||||
@classmethod
|
||||
def load_from(cls, tree, path: PathInfo, select_keys=None) -> "Context":
|
||||
from dvc.utils.serialize import LOADERS
|
||||
|
||||
file = relpath(path)
|
||||
if not tree.exists(path):
|
||||
raise ParamsLoadError(f"'{file}' does not exist")
|
||||
|
||||
@@ -6,7 +6,6 @@ from functools import singledispatch
|
||||
from funcy import memoize, rpartial
|
||||
|
||||
from dvc.exceptions import DvcException
|
||||
from dvc.utils import colorize
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
from typing import List, Match
|
||||
@@ -84,6 +83,8 @@ def _(obj: bool):
|
||||
def _format_exc_msg(exc: "ParseException"):
|
||||
from pyparsing import ParseException
|
||||
|
||||
from dvc.utils import colorize
|
||||
|
||||
exc.loc += 2 # 2 because we append `${` at the start of expr below
|
||||
|
||||
expr = exc.pstr
|
||||
|
||||
Reference in New Issue
Block a user