Пример #1
0
    def _is_enabled(cmd=None):
        from dvc.config import Config
        from dvc.repo import Repo
        from dvc.exceptions import NotDvcRepoError
        from dvc.command.daemon import CmdDaemonBase

        if os.getenv("DVC_TEST"):
            return False

        if isinstance(cmd, CmdDaemonBase):
            return False

        if cmd is None or not hasattr(cmd, "config"):
            try:
                dvc_dir = Repo.find_dvc_dir()
                config = Config(dvc_dir)
                assert config is not None
            except NotDvcRepoError:
                config = Config(validate=False)
                assert config is not None
        else:
            config = cmd.config
            assert config is not None

        core = config.config.get(Config.SECTION_CORE, {})
        enabled = core.get(Config.SECTION_CORE_ANALYTICS, True)
        logger.debug(
            "Analytics is {}abled.".format("en" if enabled else "dis"))
        return enabled
Пример #2
0
    def __init__(
        self,
        dvc_dir=None,
        validate=True,
        fs=None,
        config=None,
    ):  # pylint: disable=super-init-not-called
        from dvc.fs.local import LocalFileSystem

        self.dvc_dir = dvc_dir

        if not dvc_dir:
            try:
                from dvc.repo import Repo

                self.dvc_dir = os.path.join(Repo.find_dvc_dir())
            except NotDvcRepoError:
                self.dvc_dir = None
        else:
            self.dvc_dir = os.path.abspath(os.path.realpath(dvc_dir))

        self.wfs = LocalFileSystem(None, {"url": self.dvc_dir})
        self.fs = fs or self.wfs

        self.load(validate=validate, config=config)
Пример #3
0
    def _is_enabled(cmd=None):
        from dvc.config import Config
        from dvc.repo import Repo
        from dvc.exceptions import NotDvcRepoError
        from dvc.command.daemon import CmdDaemonBase

        if os.getenv("DVC_TEST"):
            return False

        if isinstance(cmd, CmdDaemonBase):
            return False

        if cmd is None or not hasattr(cmd, "config"):
            try:
                dvc_dir = Repo.find_dvc_dir()
                config = Config(dvc_dir)
                assert config is not None
            except NotDvcRepoError:
                config = Config(validate=False)
                assert config is not None
        else:
            config = cmd.config
            assert config is not None

        enabled = Analytics._is_enabled_config(config)
        logger.debug(
            "Analytics is {}.".format("enabled" if enabled else "disabled")
        )
        return enabled
Пример #4
0
    def _get_current_config():
        from dvc.config import Config
        from dvc.repo import Repo
        from dvc.exceptions import NotDvcRepoError

        try:
            dvc_dir = Repo.find_dvc_dir()
            config = Config(dvc_dir)
        except NotDvcRepoError:
            config = Config(validate=False)
        return config
Пример #5
0
    def __init__(self, dvc_dir=None, validate=True):
        self.dvc_dir = dvc_dir

        if not dvc_dir:
            try:
                from dvc.repo import Repo

                self.dvc_dir = os.path.join(Repo.find_dvc_dir())
            except NotDvcRepoError:
                self.dvc_dir = None
        else:
            self.dvc_dir = os.path.abspath(os.path.realpath(dvc_dir))

        self.load(validate=validate)
Пример #6
0
    def __init__(
        self, dvc_dir=None, validate=True, tree=None,
    ):  # pylint: disable=super-init-not-called
        from dvc.tree.local import LocalRemoteTree

        self.dvc_dir = dvc_dir

        if not dvc_dir:
            try:
                from dvc.repo import Repo

                self.dvc_dir = os.path.join(Repo.find_dvc_dir())
            except NotDvcRepoError:
                self.dvc_dir = None
        else:
            self.dvc_dir = os.path.abspath(os.path.realpath(dvc_dir))

        self.wtree = LocalRemoteTree(None, {"url": self.dvc_dir})
        self.tree = tree.tree if tree else self.wtree

        self.load(validate=validate)