示例#1
0
def make_checkpoint():
    """
    Signal DVC to create a checkpoint experiment.

    If the current process is being run from DVC, this function will block
    until DVC has finished creating the checkpoint. Otherwise, this function
    will return immediately.
    """
    import builtins
    from time import sleep

    from dvc.env import DVC_CHECKPOINT, DVC_ROOT
    from dvc.stage.monitor import CheckpointTask

    if os.getenv(DVC_CHECKPOINT) is None:
        return

    root_dir = os.getenv(DVC_ROOT, Repo.find_root())
    signal_file = os.path.join(root_dir, Repo.DVC_DIR, "tmp",
                               CheckpointTask.SIGNAL_FILE)

    with builtins.open(signal_file, "w", encoding="utf-8") as fobj:
        # NOTE: force flushing/writing empty file to disk, otherwise when
        # run in certain contexts (pytest) file may not actually be written
        fobj.write("")
        fobj.flush()
        os.fsync(fobj.fileno())
    while os.path.exists(signal_file):
        sleep(0.1)
示例#2
0
文件: config.py 项目: rpip/dvc
    def __init__(self, args):
        from dvc.repo import Repo, NotDvcRepoError

        self.args = args

        try:
            dvc_dir = os.path.join(Repo.find_root(), Repo.DVC_DIR)
            saved_exc = None
        except NotDvcRepoError as exc:
            dvc_dir = None
            saved_exc = exc

        self.config = Config(dvc_dir, validate=False)
        if self.args.system:
            self.configobj = self.config._system_config
        elif self.args.glob:
            self.configobj = self.config._global_config
        elif self.args.local:
            if dvc_dir is None:
                raise saved_exc
            self.configobj = self.config._local_config
        else:
            if dvc_dir is None:
                raise saved_exc
            self.configobj = self.config._repo_config
示例#3
0
def _scm_in_use():
    try:
        scm = SCM(root_dir=Repo.find_root())
        return type(scm).__name__
    except SCMError:
        return NoSCM.__name__
    except NotDvcRepoError:
        pass
示例#4
0
    def run(self):
        import os
        from dvc.repo import Repo
        from dvc.updater import Updater

        root_dir = Repo.find_root()
        dvc_dir = os.path.join(root_dir, Repo.DVC_DIR)
        updater = Updater(dvc_dir)
        updater.fetch(detach=False)

        return 0
示例#5
0
文件: config.py 项目: mathiasbc/dvc
    def _config_file_prefix(show_origin, config, level):
        if not show_origin:
            return ""

        level = level or "repo"
        fname = config.files[level]

        if level in ["local", "repo"]:
            fname = os.path.relpath(fname, start=Repo.find_root())

        return fname + "\t"
示例#6
0
文件: live.py 项目: zivzone/dvc
def summary(path: str, revs: List[str] = None):
    try:
        root = Repo.find_root()
    except NotDvcRepoError:
        root = os.getcwd()

    metrics, plots = Repo(root_dir=root,
                          uninitialized=True).live.show(path, revs)

    html_path = path + ".html"
    write(html_path, plots, metrics)
    logger.info(f"\nfile://{os.path.abspath(html_path)}")
示例#7
0
def _scm_in_use():
    from dvc.exceptions import NotDvcRepoError
    from dvc.repo import Repo
    from dvc.scm import SCM, NoSCM
    from dvc.scm.base import SCMError

    try:
        scm = SCM(root_dir=Repo.find_root())
        return type(scm).__name__
    except SCMError:
        return NoSCM.__name__
    except NotDvcRepoError:
        pass
示例#8
0
文件: daemon.py 项目: zeta1999/dvc
    def run(self):
        import os
        from dvc.repo import Repo
        from dvc.config import Config
        from dvc.updater import Updater

        root_dir = Repo.find_root()
        dvc_dir = os.path.join(root_dir, Repo.DVC_DIR)
        config = Config(dvc_dir, validate=False)
        hardlink_lock = config.get("core", {}).get("hardlink_lock", False)
        updater = Updater(dvc_dir, hardlink_lock=hardlink_lock)
        updater.fetch(detach=False)

        return 0
示例#9
0
    def collect(self):
        """Collect analytics report."""
        from dvc.scm import SCM
        from dvc.utils import is_binary
        from dvc.repo import Repo
        from dvc.exceptions import NotDvcRepoError

        self.info[self.PARAM_DVC_VERSION] = __version__
        self.info[self.PARAM_IS_BINARY] = is_binary()
        self.info[self.PARAM_USER_ID] = self._get_user_id()

        self.info[self.PARAM_SYSTEM_INFO] = self._collect_system_info()

        try:
            scm = SCM(root_dir=Repo.find_root())
            self.info[self.PARAM_SCM_CLASS] = type(scm).__name__
        except NotDvcRepoError:
            pass
示例#10
0
文件: root.py 项目: ye-man/dvc
 def run(self):
     logger.info(relpath(Repo.find_root()))
     return 0
示例#11
0
    def run(self):
        from dvc.repo import Repo

        logger.info(relpath(Repo.find_root()))
        return 0
示例#12
0
文件: root.py 项目: vishalbelsare/dvc
    def run(self):
        from dvc.repo import Repo
        from dvc.ui import ui

        ui.write(relpath(Repo.find_root()))
        return 0