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)
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
def _scm_in_use(): try: scm = SCM(root_dir=Repo.find_root()) return type(scm).__name__ except SCMError: return NoSCM.__name__ except NotDvcRepoError: pass
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
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"
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)}")
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
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
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
def run(self): logger.info(relpath(Repo.find_root())) return 0
def run(self): from dvc.repo import Repo logger.info(relpath(Repo.find_root())) return 0
def run(self): from dvc.repo import Repo from dvc.ui import ui ui.write(relpath(Repo.find_root())) return 0