def show(): """Show the current cli, client, and user configs.""" _config = ClientConfigManager.get_config_or_default() Printer.print_header("Client config:") dict_tabulate(_config.to_dict()) _config = CliConfigManager.get_config_or_default() if _config: Printer.print_header("CLI config:") if _config.current_version: click.echo("Version {}".format(_config.current_version)) else: Printer.print_warning("This cli is not configured.") if _config.installation: config_installation = dict_to_tabulate( _config.installation, humanize_values=True, exclude_attrs=["hmac", "auth", "host"], ) dict_tabulate(config_installation) else: Printer.print_warning( "This cli is not connected to a Polyaxon Host.") _config = UserConfigManager.get_config_or_default() if _config: Printer.print_header("User config:") config_user = dict_to_tabulate( _config.to_dict(), humanize_values=True, exclude_attrs=["theme"], ) dict_tabulate(config_user)
def get_run_details(run): # pylint:disable=redefined-outer-name if run.description: Printer.print_header("Run description:") click.echo("{}\n".format(run.description)) if run.inputs: Printer.print_header("Run inputs:") dict_tabulate(run.inputs) if run.outputs: Printer.print_header("Run outputs:") dict_tabulate(run.outputs) response = Printer.add_status_color(run.to_dict()) response = dict_to_tabulate( response, humanize_values=True, exclude_attrs=[ "project", "description", "readme", "content", "raw_content", "inputs", "outputs", "is_managed", ], ) Printer.print_header("Run info:") dict_tabulate(response)
def get_project_details(project): if project.description: Printer.print_header("Project description:") click.echo("{}\n".format(project.description)) response = dict_to_tabulate(project.to_dict(), humanize_values=True, exclude_attrs=["description"]) Printer.print_header("Project info:") dict_tabulate(response)
def get_model_version_details(response): metadata = response.metadata response = dict_to_tabulate( response.to_dict(), humanize_values=True, exclude_attrs=["metadata"] ) Printer.print_header("Model version info:") dict_tabulate(response) if metadata: Printer.print_header("Metadata:") click.echo(metadata)
def whoami(): """Show current logged Polyaxon user.""" try: polyaxon_client = PolyaxonClient() 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) response = dict_to_tabulate(user.to_dict(), exclude_attrs=["role"]) Printer.print_header("User info:") dict_tabulate(response)
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 get_component_version_details(response): content = response.content response = dict_to_tabulate(response.to_dict(), humanize_values=True, exclude_attrs=["content"]) Printer.print_header("Component info:") dict_tabulate(response) if content: specification = get_specification(data=content) get_specification_details(specification) else: Printer.print_warning( "This component version does not have any polyaxonfile content!")
def whoami(): """Show current logged Polyaxon Cloud or Polyaxon EE user.""" try: polyaxon_client = PolyaxonClient() user = polyaxon_client.users_v1.get_user() except ApiException as e: if e.status == 403: session_expired() handle_cli_error(e, message="Could not get the user info.", sys_exit=True) except (ApiException, HTTPError) as e: handle_cli_error(e, message="Could not load user info.", sys_exit=True) response = dict_to_tabulate(user.to_dict(), exclude_attrs=["role"]) Printer.print_header("User info:") dict_tabulate(response)
def get_entity_details(entity: str, entity_name: str): if entity.description: Printer.print_header("{} description:".format(entity_name)) click.echo("{}\n".format(entity.description)) if entity.settings: Printer.print_header("{} settings:".format(entity_name)) click.echo("{}\n".format(entity.settings.to_dict())) response = dict_to_tabulate( entity.to_dict(), humanize_values=True, exclude_attrs=["description", "settings", "readme"], ) Printer.print_header("{} info:".format(entity_name)) dict_tabulate(response)