Esempio n. 1
0
    def _get_update_instructions(self):
        instructions = {
            "pip":
            "Run {yellow}pip{reset} install dvc {blue}--upgrade{reset}",
            "yum":
            "Run {yellow}yum{reset} update dvc",
            "yay":
            "Run {yellow}yay{reset} {blue}-S{reset} dvc",
            "formula":
            "Run {yellow}brew{reset} upgrade dvc",
            "apt": ("Run {yellow}apt-get{reset} install"
                    " {blue}--only-upgrade{reset} dvc"),
            "binary": ("To upgrade follow these steps:\n"
                       "1. Uninstall dvc binary\n"
                       "2. Go to {blue}https://dvc.org{reset}\n"
                       "3. Download and install new binary"),
            "conda":
            "Run {yellow}conda{reset} {update}update{reset} dvc",
            None: ("Find the latest release at\n{blue}"
                   "https://github.com/iterative/dvc/releases/latest"
                   "{reset}"),
        }

        package_manager = get_package_manager()

        return instructions[package_manager]
Esempio n. 2
0
    def run(self):
        from dvc.repo import Repo

        dvc_version = __version__
        python_version = platform.python_version()
        platform_type = platform.platform()
        binary = is_binary()
        package_manager = get_package_manager()
        info = (
            "DVC version: {dvc_version}\n"
            "Python version: {python_version}\n"
            "Platform: {platform_type}\n"
            "Binary: {binary}\n"
            "Package manager: {package_manager}\n"
        ).format(
            dvc_version=dvc_version,
            python_version=python_version,
            platform_type=platform_type,
            binary=binary,
            package_manager=package_manager,
        )

        try:
            repo = Repo()
            root_directory = repo.root_dir

            # cache_dir might not exist yet (e.g. after `dvc init`), and we
            # can't auto-create it, as it might cause issues if the user
            # later decides to enable shared cache mode with
            # `dvc config cache.shared group`.
            if os.path.exists(repo.cache.local.cache_dir):
                info += "Cache: {cache}\n".format(
                    cache=self.get_linktype_support_info(repo)
                )
            else:
                logger.warning(
                    "Unable to detect supported link types, as cache "
                    "directory '{}' doesn't exist. It is usually auto-created "
                    "by commands such as `dvc add/fetch/pull/run/import`, "
                    "but you could create it manually to enable this "
                    "check.".format(relpath(repo.cache.local.cache_dir))
                )

            if psutil:
                info += (
                    "Filesystem type (cache directory): {fs_cache}\n"
                ).format(fs_cache=self.get_fs_type(repo.cache.local.cache_dir))
        except NotDvcRepoError:
            root_directory = os.getcwd()

        if psutil:
            info += ("Filesystem type (workspace): {fs_root}").format(
                fs_root=self.get_fs_type(os.path.abspath(root_directory))
            )

        logger.info(info)
        return 0