How to use the polyaxon.utils.formatting.Printer.print_success function in polyaxon

To help you get started, we’ve selected a few polyaxon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github polyaxon / polyaxon / cli / polyaxon / cli / runs.py View on Github external
\b
    ```bash
    $ polyaxon runs -uid=8aac02e3a62a4f0aaa257c59da5eab80 bookmark
    ```
    """
    owner, project_name, run_uuid = get_project_run_or_local(
        ctx.obj.get("project"), ctx.obj.get("run_uuid")
    )
    try:
        polyaxon_client = PolyaxonClient()
        polyaxon_client.runs_v1.bookmark_run(owner, project_name, run_uuid)
    except (ApiException, HTTPError) as e:
        handle_cli_error(e, message="Could not bookmark run `{}`.".format(run_uuid))
        sys.exit(1)

    Printer.print_success("Run is bookmarked.")
github polyaxon / polyaxon / cli / polyaxon / cli / runs.py View on Github external
ctx.obj.get("project"), ctx.obj.get("run_uuid")
    )
    if not yes and not click.confirm(
        "Are sure you want to stop " "run `{}`".format(run_uuid)
    ):
        click.echo("Existing without stopping run.")
        sys.exit(0)

    try:
        polyaxon_client = PolyaxonClient()
        polyaxon_client.runs_v1.stop_run(owner, project_name, run_uuid)
    except (ApiException, HTTPError) as e:
        handle_cli_error(e, message="Could not stop run `{}`.".format(run_uuid))
        sys.exit(1)

    Printer.print_success("Run is being stopped.")
github polyaxon / polyaxon / cli / polyaxon / cli / upload.py View on Github external
PolyaxonClientException,
                ) as e:
                    handle_cli_error(
                        e,
                        message="Could not upload code for project `{}`.".format(
                            project.name
                        ),
                    )
                    Printer.print_error(
                        "Check the project exists, "
                        "and that you have access rights, "
                        "this could happen as well when uploading large files. "
                        "Please also make sure that you have enough space to upload the data."
                    )
                    sys.exit(1)
                Printer.print_success("Files uploaded.")
    except Exception as e:
        handle_cli_error(e, message="Could not upload the file.")
        sys.exit(1)
github polyaxon / polyaxon / cli / polyaxon / cli / auth.py View on Github external
return

        access_auth = polyaxon_sdk.models.V1Auth(token=token.strip(" "))

    # Set user
    try:
        AuthConfigManager.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)
    polyaxon_client.config.token = access_auth.token
    Printer.print_success("Login successful")

    # Reset current cli
    server_versions = get_server_versions(polyaxon_client=polyaxon_client)
    current_version = get_current_version()
    log_handler = get_log_handler(polyaxon_client=polyaxon_client)
    CliConfigManager.reset(
        check_count=0,
        current_version=current_version,
        server_versions=server_versions.to_dict(),
        log_handler=log_handler,
    )
github polyaxon / polyaxon / cli / polyaxon / cli / admin.py View on Github external
def deploy(config_file, manager_path, check, dry_run):
    """Deploy polyaxon."""
    config = read_deployment_config(config_file)
    manager = DeployManager(
        config=config, filepath=config_file, manager_path=manager_path, dry_run=dry_run
    )
    exception = None
    if check:
        try:
            manager.check()
        except Exception as e:
            handle_cli_error(e, message="Polyaxon deployment file is not valid.")
            sys.exit(1)

        Printer.print_success("Polyaxon deployment file is valid.")
    else:
        try:
            manager.install()
        except Exception as e:
            Printer.print_error("Polyaxon could not be installed.")
            exception = e

    if exception:
        Printer.print_error("Error message: {}.".format(exception))
github polyaxon / polyaxon / cli / polyaxon / cli / runs.py View on Github external
content = "{}".format(reader.read(polyaxonfile))

    # Check if we need to upload
    if u:
        ctx.invoke(upload, sync=False)

    owner, project_name, run_uuid = get_project_run_or_local(
        ctx.obj.get("project"), ctx.obj.get("run_uuid")
    )
    try:
        polyaxon_client = PolyaxonClient()
        body = V1Run(content=content)
        response = polyaxon_client.runs_v1.resume_run(
            owner, project_name, run_uuid, body
        )
        Printer.print_success("Run was resumed with uid {}".format(response.uuid))
    except (ApiException, HTTPError) as e:
        handle_cli_error(e, message="Could not resume run `{}`.".format(run_uuid))
        sys.exit(1)
github polyaxon / polyaxon / cli / polyaxon / managers / deploy.py View on Github external
delete_tar=True,
            extract_path=path,
        )
        # Move necessary info
        shutil.copy(
            path + "/polyaxon-compose-master/docker-compose.yml",
            path + "/docker-compose.yml",
        )
        shutil.copy(
            path + "/polyaxon-compose-master/components.env", path + "/components.env"
        )
        shutil.copy(path + "/polyaxon-compose-master/base.env", path + "/base.env")
        shutil.rmtree(path + "/polyaxon-compose-master/")
        # Generate env from config
        ComposeConfigManager.set_config(self.compose.generate_env(self.config))
        Printer.print_success("Docker Compose deployment is initialised.")
        if self.dry_run:
            Printer.print_success("Polyaxon generated deployment env.")
            return
        self.docker.execute(["volume", "create", "--name=polyaxon-postgres"])
        Printer.print_success("Docker volume created.")
        self.compose.execute(["-f", path + "/docker-compose.yml", "up", "-d"])
        Printer.print_success("Deployment is running in the background.")
        Printer.print_success(
            "You can configure your CLI by running: "
            "polyaxon config set --host=localhost."
github polyaxon / polyaxon / cli / polyaxon / managers / deploy.py View on Github external
)
        # Move necessary info
        shutil.copy(
            path + "/polyaxon-compose-master/docker-compose.yml",
            path + "/docker-compose.yml",
        )
        shutil.copy(
            path + "/polyaxon-compose-master/components.env", path + "/components.env"
        )
        shutil.copy(path + "/polyaxon-compose-master/base.env", path + "/base.env")
        shutil.rmtree(path + "/polyaxon-compose-master/")
        # Generate env from config
        ComposeConfigManager.set_config(self.compose.generate_env(self.config))
        Printer.print_success("Docker Compose deployment is initialised.")
        if self.dry_run:
            Printer.print_success("Polyaxon generated deployment env.")
            return
        self.docker.execute(["volume", "create", "--name=polyaxon-postgres"])
        Printer.print_success("Docker volume created.")
        self.compose.execute(["-f", path + "/docker-compose.yml", "up", "-d"])
        Printer.print_success("Deployment is running in the background.")
        Printer.print_success(
            "You can configure your CLI by running: "
            "polyaxon config set --host=localhost."
github polyaxon / polyaxon / cli / polyaxon / managers / deploy.py View on Github external
def upgrade_on_kubernetes(self):
        args = ["upgrade", "polyaxon"]
        if self.manager_path:
            args += [self.manager_path]
        else:
            args += ["polyaxon/polyaxon"]
        if self.filepath:
            args += ["-f", self.filepath]
        if self.deployment_version:
            args += ["--version", self.deployment_version]
        if self.dry_run:
            args += ["--debug", "--dry-run"]
        click.echo("Running upgrade command ...")
        stdout = self.helm.execute(args=args)
        click.echo(stdout)
        Printer.print_success("Deployment upgraded.")
github polyaxon / polyaxon / cli / polyaxon / managers / deploy.py View on Github external
args += [self.manager_path]
        else:
            args += ["polyaxon/polyaxon"]

        args += ["--name=polyaxon", "--namespace=polyaxon"]
        if self.filepath:
            args += ["-f", self.filepath]
        if self.deployment_version:
            args += ["--version", self.deployment_version]
        if self.dry_run:
            args += ["--debug", "--dry-run"]

        click.echo("Running install command ...")
        stdout = self.helm.execute(args=args)
        click.echo(stdout)
        Printer.print_success("Deployment finished.")