def version(check): """Print the current version of the cli and platform.""" Printer.print_header("Current cli version: {}.".format(pkg.VERSION)) if check: config = set_versions_config() Printer.print_header("Platform:") dict_tabulate(config.installation) Printer.print_header("compatibility versions:") dict_tabulate(config.compatibility) check_cli_version(config)
def version(check): """Print the current version of the cli and platform.""" Printer.print_header("Current cli version: {}.".format(pkg.VERSION)) if check: config = set_versions_config() Printer.print_header("Platform:") config_installation = dict_to_tabulate( config.installation, humanize_values=True, exclude_attrs=["hmac", "auth", "host"], ) dict_tabulate(config_installation) Printer.print_header("Compatibility versions:") dict_tabulate(config.compatibility) check_cli_version(config)
def cli(context, verbose, offline): """Polyaxon - Cloud Native Machine Learning Automation & Experimentation tool. This CLI provides tools to: - Parse, Validate, and Check Polyaxonfiles. - Interact with Polyaxon server. - Run and Monitor experiments and jobs. This CLI tool comes with a caching mechanism: - You can initialize a project with: polyaxon init [project name] - Otherwise Polyaxon will the default global path will be used for the cache. You can check the version of you CLI by running: - polyaxon version To Enable debug mode, you can use the `-v` flag: - polyaxon -v admin Common commands: - polyaxon project get - polyaxon run [-f] [-l] - polyaxon ops ls - polyaxon ops get - polyaxon config -l - polyaxon config set ... Admin deployment commands: - polyaxon admin deploy [-f] [--check] - polyaxon admin upgrade [-f] [--check] - polyaxon admin teardown [-f] For more information, please visit https://polyaxon.com/docs/core/cli/ Check the help available for each command listed below. """ settings.set_cli_config() configure_logger(verbose) non_check_cmds = [ "completion", "config", "version", "login", "logout", "deploy", "admin", "teardown", "docker", "initializer", "sidecar", "proxy", "notify", "upgrade", "port-forward", ] context.obj = context.obj or {} if not settings.CLIENT_CONFIG.client_header: settings.CLIENT_CONFIG.set_cli_header() context.obj["offline"] = offline if offline: os.environ["POLYAXON_IS_OFFLINE"] = "true" settings.CLIENT_CONFIG.is_offline = True if not (context.invoked_subcommand in non_check_cmds or offline or settings.CLIENT_CONFIG.no_api or settings.CLIENT_CONFIG.is_ops or DOCS_GEN) and settings.CLI_CONFIG.should_check( settings.CLIENT_CONFIG.compatibility_check_interval): cli_config = set_versions_config() check_cli_version(cli_config)
def login(token, username, password): """Login to Polyaxon Cloud or Polyaxon EE.""" if not settings.CLI_CONFIG or settings.CLI_CONFIG.is_ce: handle_command_not_in_ce() polyaxon_client = PolyaxonClient() if username and not token: # Use user or email / password login if not password: password = click.prompt("Please enter your password", type=str, hide_input=True) password = password.strip() if not password: logger.info( "You entered an empty string. " "Please make sure you enter your password correctly.") sys.exit(1) try: body = V1Credentials(username=username, password=password) access_auth = polyaxon_client.auth_v1.login(body=body) except (ApiException, HTTPError) as e: AuthConfigManager.purge() UserConfigManager.purge() CliConfigManager.purge() handle_cli_error(e, message="Could not login.") sys.exit(1) if not access_auth.token: Printer.print_error("Failed to login") return else: if not token: token_url = get_dashboard_url(subpath="profile/token") click.confirm( "Authentication token page will now open in your browser. Continue?", abort=True, default=True, ) click.launch(token_url) logger.info("Please copy and paste the authentication token.") token = click.prompt( "This is an invisible field. Paste token and press ENTER", type=str, hide_input=True, ) if not token: logger.info( "Empty token received. " "Make sure your shell is handling the token appropriately.") logger.info( "See docs for help: http://polyaxon.com/docs/polyaxon_cli/commands/auth" ) return access_auth = polyaxon_sdk.models.V1Auth(token=token.strip(" ")) # Set user try: AuthConfigManager.purge() UserConfigManager.purge() polyaxon_client = PolyaxonClient(token=access_auth.token) user = polyaxon_client.users_v1.get_user() except (ApiException, HTTPError) as e: handle_cli_error(e, message="Could not load user info.") sys.exit(1) access_token = AccessTokenConfig(username=user.username, token=access_auth.token) AuthConfigManager.set_config(access_token) UserConfigManager.set_config(user) polyaxon_client.config.token = access_auth.token Printer.print_success("Login successful") set_versions_config(polyaxon_client=polyaxon_client, set_handler=True)
def cli(context, verbose, offline): """Polyaxon - Cloud Native Machine Learning Automation & Experimentation tool. This CLI provides tools to: - Parse, Validate, and Check Polyaxonfiles. - Interact with Polyaxon server. - Run and Monitor experiments and jobs. This CLI tool comes with a caching mechanism: - You can initialize a project with: polyaxon init -p [project name] - Otherwise Polyaxon will use the default global path for the cache. You can check the version of your CLI by running: - polyaxon version To can check the version of the CLI and the server, and check the compatibility matrix: - polyaxon version --check To Enable debug mode, you can use the `-v` flag: - polyaxon -v ... To configure your host: - polyaxon config set --host=... To check your current config: - polyaxon config show Common commands: - polyaxon project get - polyaxon run [-f] [-l] - polyaxon ops ls - polyaxon ops logs - polyaxon ops get - polyaxon config set ... Admin deployment commands: - polyaxon admin deploy [-f] [--check] - polyaxon admin upgrade [-f] [--check] - polyaxon admin teardown [-f] For more information, please visit https://polyaxon.com/docs/core/cli/ Check the help available for each command listed below by appending `-h`. """ settings.set_cli_config() configure_logger(verbose) if settings.CLIENT_CONFIG.no_op: Printer.print_warning( "POLYAXON_NO_OP is set to `true`, some commands will not function correctly." ) context.obj = context.obj or {} if not settings.CLIENT_CONFIG.client_header: settings.CLIENT_CONFIG.set_cli_header() context.obj["offline"] = offline if offline: os.environ["POLYAXON_IS_OFFLINE"] = "true" settings.CLIENT_CONFIG.is_offline = True non_check_cmds = [ "completion", "config", "version", "login", "logout", "deploy", "admin", "teardown", "docker", "initializer", "sidecar", "proxy", "notify", "upgrade", "port-forward", ] if not settings.CLI_CONFIG.installation: pass if (not (context.invoked_subcommand in non_check_cmds or offline or settings.CLIENT_CONFIG.no_api or settings.CLIENT_CONFIG.is_ops or DOCS_GEN) and not settings.CLI_CONFIG.installation): cli_config = set_versions_config(is_cli=False) settings.CLI_CONFIG = cli_config check_cli_version(cli_config, is_cli=False)