Esempio n. 1
0
def check_cli_version(config, is_cli: bool = True):
    """Check if the current cli version satisfies the server requirements"""
    from distutils.version import LooseVersion  # pylint:disable=import-error

    min_version = clean_version_for_check(config.min_version)
    latest_version = clean_version_for_check(config.latest_version)
    current_version = clean_version_for_check(config.current_version)
    if not min_version or not latest_version or not current_version:
        if is_cli:
            Printer.print_error(
                "Could not get the min/latest versions from compatibility API.",
                sys_exit=True,
            )
        else:
            return
    if LooseVersion(current_version) < LooseVersion(min_version):
        click.echo(
            """Your version of CLI ({}) is no longer compatible with server.""".format(
                config.current_version
            )
        )
        if click.confirm(
            "Do you want to upgrade to " "version {} now?".format(config.latest_version)
        ):
            pip_upgrade()
            sys.exit(0)
        else:
            indentation.puts("Your can manually run:")
            with indentation.indent(4):
                indentation.puts("pip install -U polyaxon")
            indentation.puts(
                "to upgrade to the latest version `{}`".format(config.latest_version)
            )

            sys.exit(0)
    elif LooseVersion(current_version) < LooseVersion(latest_version):
        indentation.puts(
            "New version of CLI ({}) is now available. To upgrade run:".format(
                config.latest_version
            )
        )
        with indentation.indent(4):
            indentation.puts("pip install -U polyaxon")
    elif LooseVersion(current_version) > LooseVersion(latest_version):
        indentation.puts(
            "Your version of CLI ({}) is ahead of the latest version "
            "supported by Polyaxon Platform ({}) on your cluster, "
            "and might be incompatible.".format(
                config.current_version, config.latest_version
            )
        )
Esempio n. 2
0
 def sync(self):
     self.client.agents_v1.sync_agent(
         owner=self.owner,
         agent_uuid=self.agent_uuid,
         body=V1Agent(
             content=settings.AGENT_CONFIG.to_dict(dump=True),
             version=clean_version_for_check(pkg.VERSION),
             version_api=self.spawner.k8s_manager.get_version(),
         ),
     )