Misc imports lazy (#5215)

This commit is contained in:
Saugat Pachhai
2021-01-06 17:50:24 +05:45
committed by GitHub
parent 4c53e636bc
commit 9b73a745b4
3 changed files with 12 additions and 4 deletions
+2 -1
View File
@@ -5,7 +5,6 @@ import os
from dvc.command import completion
from dvc.command.base import CmdBase, append_doc_link, fix_subparsers
from dvc.exceptions import DvcException
from dvc.schema import PLOT_PROPS
from dvc.utils import format_link
from dvc.utils.html import write
@@ -17,6 +16,8 @@ class CmdPlots(CmdBase):
raise NotImplementedError
def _props(self):
from dvc.schema import PLOT_PROPS
# Pass only props specified by user, to not shadow ones from plot def
props = {p: getattr(self.args, p) for p in PLOT_PROPS}
return {k: v for k, v in props.items() if v is not None}
+9 -1
View File
@@ -3,7 +3,6 @@ import logging
from dvc.command.base import append_doc_link, fix_subparsers
from dvc.command.config import CmdConfig
from dvc.config import ConfigError, merge
from dvc.utils import format_link
logger = logging.getLogger(__name__)
@@ -17,12 +16,16 @@ class CmdRemote(CmdConfig):
self.args.name = self.args.name.lower()
def _check_exists(self, conf):
from dvc.config import ConfigError
if self.args.name not in conf["remote"]:
raise ConfigError(f"remote '{self.args.name}' doesn't exist.")
class CmdRemoteAdd(CmdRemote):
def run(self):
from dvc.config import ConfigError
if self.args.default:
logger.info(f"Setting '{self.args.name}' as a default remote.")
@@ -61,6 +64,8 @@ class CmdRemoteRemove(CmdRemote):
class CmdRemoteModify(CmdRemote):
def run(self):
from dvc.config import merge
with self.config.edit(self.args.level) as conf:
merged = self.config.load_config_to_level(self.args.level)
merge(merged, conf)
@@ -78,6 +83,7 @@ class CmdRemoteModify(CmdRemote):
class CmdRemoteDefault(CmdRemote):
def run(self):
from dvc.config import ConfigError
if self.args.name is None and not self.args.unset:
conf = self.config.read(self.args.level)
@@ -120,6 +126,8 @@ class CmdRemoteRename(CmdRemote):
conf["core"]["remote"] = self.args.new
def run(self):
from dvc.config import ConfigError
all_config = self.config.load_config_to_level(None)
if self.args.new in all_config.get("remote", {}):
raise ConfigError(
+1 -2
View File
@@ -5,7 +5,6 @@ from functools import wraps
from typing import TYPE_CHECKING
from funcy import cached_property, cat
from git import InvalidGitRepositoryError
from dvc.config import Config
from dvc.exceptions import FileMissingError
@@ -113,7 +112,7 @@ class Repo:
try:
scm = SCM(root_dir or os.curdir)
except (SCMError, InvalidGitRepositoryError):
except SCMError:
scm = SCM(os.curdir, no_scm=True)
assert isinstance(scm, Base)