How to use the polyaxon.client.PolyaxonClient 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 / tests / test_utils / test_polyaxon_clients.py View on Github external
def test_client(self, get_value_mock1, get_value_mock2):
        get_value_mock1.return_value = "token"
        get_value_mock2.return_value = "host"
        client = PolyaxonClient()

        assert client.host == "host"
        assert client.token == "token"
github polyaxon / polyaxon / cli / polyaxon / cli / version.py View on Github external
def get_server_versions(polyaxon_client=None):
    polyaxon_client = polyaxon_client or PolyaxonClient()
    try:
        return polyaxon_client.versions_v1.get_versions()
    except ApiException as e:
        if e.status == 403:
            session_expired()
            sys.exit(1)
        handle_cli_error(e, message="Could not get cli version.")
        sys.exit(1)
    except HTTPError:
        Printer.print_error("Could not connect to remote server.")
        sys.exit(1)
github polyaxon / polyaxon / cli / polyaxon / cli / runs.py View on Github external
```bash
    $ polyaxon runs --project=cats-vs-dogs -id 8aac02e3a62a4f0aaa257c59da5eab80 get
    ```

    \b
    ```bash
    $ polyaxon runs -p alain/cats-vs-dogs --uid=8aac02e3a62a4f0aaa257c59da5eab80 get
    ```
    """

    owner, project_name, run_uuid = get_project_run_or_local(
        ctx.obj.get("project"), ctx.obj.get("run_uuid")
    )

    try:
        polyaxon_client = PolyaxonClient()
        response = polyaxon_client.runs_v1.get_run(owner, project_name, run_uuid)
        config = polyaxon_client.api_client.sanitize_for_serialization(response)
        cache.cache(config_manager=RunManager, response=config)
    except (ApiException, HTTPError) as e:
        handle_cli_error(e, message="Could not load run `{}` info.".format(run_uuid))
        sys.exit(1)

    get_run_details(response)
github polyaxon / polyaxon / polyaxon / cli / notebook.py View on Github external
Uses [Caching](/references/polyaxon-cli/#caching)
    """
    user, project_name = get_project_or_local(ctx.obj.get("project"))

    if not yes and not click.confirm(
        "Are sure you want to stop notebook "
        "for project `{}/{}`".format(user, project_name)
    ):
        click.echo("Existing without stopping notebook.")
        sys.exit(1)

    if commit is None:
        commit = True

    try:
        PolyaxonClient().project.stop_notebook(user, project_name, commit)
        Printer.print_success("Notebook is being deleted")
    except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:
        Printer.print_error(
            "Could not stop notebook project `{}`.".format(project_name)
        )
        Printer.print_error("Error message `{}`.".format(e))
        sys.exit(1)
github polyaxon / polyaxon / cli / polyaxon / cli / bookmark.py View on Github external
\b
    ```bash
    $ polyaxon bookmark experiments
    ```

    \b
    ```bash
    $ polyaxon bookmark -u adam experiments
    ```
    """
    user = get_username_or_local(ctx.obj.get("username"))

    try:
        params = get_query_params(limit=limit, offset=offset)
        polyaxon_client = PolyaxonClient()
        response = polyaxon_client.runs_v1.list_bookmarked_runs(user, **params)
    except (ApiException, HTTPError) as e:
        handle_cli_error(
            e,
            message="Could not get bookmarked experiments for user `{}`.".format(user),
        )
        sys.exit(1)

    meta = get_meta_response(response)
    if meta:
        Printer.print_header("Bookmarked experiments for user `{}`.".format(user))
        Printer.print_header("Navigation:")
        dict_tabulate(meta)
    else:
        Printer.print_header(
            "No bookmarked experiments found for user `{}`.".format(user)
github polyaxon / polyaxon / polyaxon / cli / notebook.py View on Github external
def url(ctx):
    """Prints the notebook url for this project.

    Uses [Caching](/references/polyaxon-cli/#caching)

    Example:

    \b
    ```bash
    $ polyaxon notebook url
    ```
    """
    user, project_name = get_project_or_local(ctx.obj.get("project"))
    try:
        response = PolyaxonClient().project.get_project(user, project_name)
    except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:
        Printer.print_error("Could not get project `{}`.".format(project_name))
        Printer.print_error("Error message `{}`.".format(e))
        sys.exit(1)

    if response.has_notebook:
        click.echo(get_notebook_url(user, project_name))
    else:
        Printer.print_warning(
            "This project `{}` does not have a running notebook.".format(project_name)
        )
        click.echo(
            "You can start a notebook with this command: polyaxon notebook start --help"
        )
github polyaxon / polyaxon / cli / polyaxon / cli / projects.py View on Github external
def git_sync_repo():
        try:
            response = PolyaxonClient().projects_v1.sync_repo(user, project_name)
        except (ApiException, HTTPError) as e:
            handle_cli_error(
                e,
                message="Could not sync git repo on project `{}`.".format(project_name),
            )
            sys.exit(1)

        click.echo(response.status_code)
        Printer.print_success("Project was successfully synced with latest changes.")
github polyaxon / polyaxon / cli / polyaxon / cli / runs.py View on Github external
\b
    ```bash
    $ polyaxon runs bookmark
    ```

    \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 / run / platform.py View on Github external
def create_run():
        click.echo("Creating a run.")
        run = V1Run(content=specification.config_dump)
        try:
            polyaxon_client = PolyaxonClient()
            response = polyaxon_client.runs_v1.create_run(owner, project_name, run)
            cache.cache(config_manager=RunManager, response=response)
            Printer.print_success("A new run `{}` was created".format(response.uuid))
        except (ApiException, HTTPError) as e:
            handle_cli_error(e, message="Could not create a run.")
            sys.exit(1)
github polyaxon / polyaxon / cli / polyaxon / cli / runs.py View on Github external
```

    \b
    ```bash
    $ polyaxon runs --project=cats-vs-dogs -id 8aac02e3a62a4f0aaa257c59da5eab80 delete
    ```
    """
    owner, project_name, run_uuid = get_project_run_or_local(
        ctx.obj.get("project"), ctx.obj.get("run_uuid")
    )
    if not click.confirm("Are sure you want to delete run `{}`".format(run_uuid)):
        click.echo("Existing without deleting the run.")
        sys.exit(1)

    try:
        polyaxon_client = PolyaxonClient()
        polyaxon_client.runs_v1.delete_run(owner, project_name, run_uuid)
        # Purge caching
        RunManager.purge()
    except (ApiException, HTTPError) as e:
        handle_cli_error(e, message="Could not delete run `{}`.".format(run_uuid))
        sys.exit(1)

    Printer.print_success("Run `{}` was delete successfully".format(run_uuid))