Skip to content

vast-ai/vast-cli / vastai

vastai

Flagged

Vast.ai CLI to manage GPU instances, volumes, serverless endpoints, and billing.

FileKindSize
SKILL.mdskill md18.6 KB
__init__.pyscript1.8 KB
_base.pyscript1.6 KB
api/__init__.pyscript31 B
api/auth.pyscript15.3 KB
api/billing.pyscript10.4 KB
api/client.pyscript9.1 KB
api/clusters.pyscript4.5 KB
api/deployments.pyscript1.4 KB
api/endpoints.pyscript12.0 KB
api/instances.pyscript17.1 KB
api/keys.pyscript4.3 KB
api/machines.pyscript7.4 KB
api/metrics.pyscript2.6 KB
api/offers.pyscript21.2 KB
api/price_increase.pyscript4.0 KB
api/query.pyscript12.2 KB
api/storage.pyscript14.5 KB
api/teams.pyscript4.4 KB
async_/__init__.pyscript79 B
async_/client.pyscript9.6 KB
async_/results.pyscript1.3 KB
cli/__init__.pyscript25 B
cli/commands/__init__.pyscript757 B
cli/commands/auth.pyscript42.8 KB
cli/commands/benchmarks.pyscript42.0 KB
cli/commands/billing.pyscript30.4 KB
cli/commands/clusters.pyscript7.8 KB
cli/commands/deployments.pyscript7.8 KB
cli/commands/endpoints.pyscript17.3 KB
cli/commands/instances.pyscript55.4 KB
cli/commands/keys.pyscript7.9 KB
cli/commands/machines.pyscript78.4 KB
cli/commands/metrics.pyscript12.7 KB
cli/commands/misc.pyscript11.0 KB
cli/commands/offers.pyscript30.0 KB
cli/commands/price_increase.pyscript14.5 KB
cli/commands/repl.pyscript719 B
cli/commands/storage.pyscript38.9 KB
cli/commands/teams.pyscript6.4 KB
cli/commands/uninstall.pyscript2.4 KB
cli/commands/update.pyscript3.1 KB
cli/display.pyscript20.1 KB
cli/main.pyscript11.5 KB
cli/parser.pyscript18.1 KB
cli/repl/__init__.pyscript318 B
cli/repl/bridge.pyscript7.3 KB
cli/repl/catalog.pyscript6.3 KB
cli/repl/completion.pyscript8.2 KB
cli/repl/session.pyscript7.3 KB
cli/self_test/__init__.pyscript46 B
cli/self_test/machine_diagnostics.pyscript21.0 KB
cli/self_test/runtime_diagnostics.pyscript18.6 KB
cli/self_test/support_bundle.pyscript11.0 KB
cli/selfupdate.pyscript14.0 KB
cli/util.pyscript26.3 KB
cli/utils.pyscript577 B
data/__init__.pyscript303 B
data/deployment.pyscript3.5 KB
data/endpoint.pyscript2.1 KB
data/instance.pyscript3.6 KB
data/offer.pyscript4.4 KB
data/query.pyscript12.8 KB
data/workergroup.pyscript1.4 KB
pdf/__init__.pyscript0 B
pdf/vast.ai-logo-50pct.pngbinary7.4 KB
pdf/vast.ai-logo.pngbinary10.1 KB
pdf/vast_pdf.pyscript19.4 KB
pdf/watcher.shexecutablescript390 B
sdk.pyscript52.2 KB
serverless/__init__.pyscript193 B
serverless/client/__init__.pyscript346 B
serverless/client/client.pyscript36.7 KB
serverless/client/connection.pyscript11.5 KB
serverless/client/endpoint.pyscript6.9 KB
serverless/client/managed.pyscript7.3 KB
serverless/client/request_status.pyscript371 B
serverless/client/session.pyscript2.8 KB
serverless/client/worker.pyscript1.3 KB
serverless/remote/__init__.pyscript245 B
serverless/remote/base.pyscript6.3 KB
serverless/remote/deploy.pyscript12.6 KB
serverless/remote/serialization.pyscript3.7 KB
serverless/remote/serve.pyscript8.6 KB
serverless/remote/serve_deployment.pyscript6.3 KB
serverless/remote/utils.pyscript9.7 KB
serverless/server/__init__.pyscript0 B
serverless/server/lib/__init__.pyscript0 B
serverless/server/lib/backend.pyscript43.3 KB
serverless/server/lib/data_types.pyscript10.6 KB
serverless/server/lib/metrics.pyscript12.2 KB
serverless/server/lib/server.pyscript3.2 KB
serverless/server/worker.pyscript17.1 KB
sync/__init__.pyscript76 B
sync/client.pyscript4.9 KB
sync/results.pyscript1.2 KB
utils.pyscript12.2 KB

cli/commands/clusters.py

View on GitHub
"""CLI commands for managing clusters and overlays."""

import json

from vastai.cli.parser import argument
from vastai.cli.display import (
    display_table, cluster_fields, overlay_fields, deindent,
)
from vastai.api import clusters as clusters_api


from vastai.cli.utils import get_parser as _get_parser, get_client  # noqa: F401


parser = _get_parser()


# ---------------------------------------------------------------------------
# clusters
# ---------------------------------------------------------------------------

@parser.command(
    argument("subnet", help="local subnet for cluster, ex: '0.0.0.0/24'", type=str),
    argument("manager_id", help="Machine ID of manager node in cluster. Must exist already.", type=int),
    usage="vastai create cluster SUBNET MANAGER_ID",
    help="Create Vast cluster",
    epilog=deindent("""
        Create Vast Cluster by defining a local subnet and manager id.""")
)
def create__cluster(args):
    """Create a Vast Cluster."""
    if args.explain:
        print("request json:", {"subnet": args.subnet, "manager_id": args.manager_id})

    client = get_client(args)
    result = clusters_api.create_cluster(client, subnet=args.subnet, manager_id=args.manager_id)

    if args.raw:
        return result

    print(result.get("msg", result))


@parser.command(
    usage="vastai show clusters",
    help="Show clusters associated with your account.",
    epilog=deindent("""
        Show clusters associated with your account.
    """)
)
def show__clusters(args):
    """Show clusters associated with your account."""
    client = get_client(args)
    response_data = clusters_api.show_clusters(client)

    if args.raw:
        return response_data

    rows = []
    for cluster_id, cluster_data in response_data['clusters'].items():
        machine_ids = [node["machine_id"] for node in cluster_data["nodes"]]
        manager_node = next(node for node in cluster_data['nodes'] if node['is_cluster_manager'])
        row_data = {
            'id': cluster_id,
            'subnet': cluster_data['subnet'],
            'node_count': len(cluster_data['nodes']),
            'machine_ids': str(machine_ids),
            'manager_id': str(manager_node['machine_id']),
            'manager_ip': manager_node['local_ip'],
        }
        rows.append(row_data)

    display_table(rows, cluster_fields, replace_spaces=False)


@parser.command(
    argument("cluster_id", help="ID of cluster to delete", type=int),
    usage="vastai delete cluster CLUSTER_ID",
    help="Delete Cluster",
    epilog=deindent("""
        Delete Vast Cluster""")
)
def delete__cluster(args):
    """Delete a Vast Cluster."""
    if args.explain:
        print("request json:", {"cluster_id": args.cluster_id})

    client = get_client(args)
    result = clusters_api.delete_cluster(client, cluster_id=args.cluster_id)

    if args.raw:
        return result
    print(result["msg"])


@parser.command(
    argument("cluster_id", help="ID of cluster to add machine to", type=int),
    argument("machine_ids", help="machine id(s) to join cluster", type=int, nargs="+"),
    usage="vastai join cluster CLUSTER_ID MACHINE_IDS",
    help="Join Machine to Cluster",
    epilog=deindent("""
        Join's Machine to Vast Cluster
    """)
)
def join__cluster(args):
    """Join machine(s) to a Vast Cluster."""
    if args.explain:
        print("request json:", {"cluster_id": args.cluster_id, "machine_ids": args.machine_ids})

    client = get_client(args)
    result = clusters_api.join_cluster(client, cluster_id=args.cluster_id, machine_ids=args.machine_ids)

    if args.raw:
        return result
    print(result["msg"])


@parser.command(
    argument("cluster_id", help="ID of cluster you want to remove machine from.", type=int),
    argument("machine_id", help="ID of machine to remove from cluster.", type=int),
    argument("new_manager_id", help="ID of machine to promote to manager. Must already be in cluster", type=int, nargs="?"),
    usage="vastai remove-machine-from-cluster CLUSTER_ID MACHINE_ID NEW_MANAGER_ID",
    help="Removes machine from cluster",
    epilog=deindent("""Removes machine from cluster and also reassigns manager ID,
    if we're removing the manager node""")
)
def remove_machine_from_cluster(args):
    """Remove a machine from a cluster."""
    if args.explain:
        print("request json:", {"cluster_id": args.cluster_id, "machine_id": args.machine_id,
                                "new_manager_id": args.new_manager_id})

    client = get_client(args)
    result = clusters_api.remove_machine_from_cluster(
        client, cluster_id=args.cluster_id, machine_id=args.machine_id,
        new_manager_id=args.new_manager_id,
    )

    if args.raw:
        return result
    print(result.get("msg", result))


# ---------------------------------------------------------------------------
# overlays
# ---------------------------------------------------------------------------

@parser.command(
    argument("cluster_id", help="ID of cluster to create overlay on top of", type=int),
    argument("name", help="overlay network name"),
    usage="vastai create overlay CLUSTER_ID OVERLAY_NAME",
    help="Creates overlay network on top of a physical cluster",
    epilog=deindent("""
    Creates an overlay network to allow local networking between instances on a physical cluster"""),
)
def create__overlay(args):
    """Create an overlay network on a physical cluster."""
    if args.explain:
        print("request json:", {"cluster_id": args.cluster_id, "name": args.name})

    client = get_client(args)
    result = clusters_api.create_overlay(client, cluster_id=args.cluster_id, name=args.name)

    if args.raw:
        return result
    print(result["msg"])


@parser.command(
    usage="vastai show overlays",
    help="Show overlays associated with your account.",
    epilog=deindent("""
        Show overlays associated with your account.
    """),
)
def show__overlays(args):
    """Show overlays associated with your account."""
    client = get_client(args)
    response_data = clusters_api.show_overlays(client)
    if args.raw:
        return response_data

    rows = []
    for overlay in response_data:
        row_data = {
            'overlay_id': overlay['overlay_id'],
            'name': overlay['name'],
            'subnet': overlay['internal_subnet'] if overlay['internal_subnet'] else 'N/A',
            'cluster_id': overlay['cluster_id'],
            'instance_count': len(overlay['instances']),
            'instances': str(overlay['instances']),
        }
        rows.append(row_data)
    display_table(rows, overlay_fields, replace_spaces=False)


@parser.command(
    argument("overlay_identifier", help="ID (int) or name (str) of overlay to delete", nargs="?"),
    usage="vastai delete overlay OVERLAY_IDENTIFIER",
    help="Deletes overlay and removes all of its associated instances",
)
def delete__overlay(args):
    """Delete an overlay network."""
    if args.explain:
        print("request json:", {"overlay_identifier": args.overlay_identifier})

    client = get_client(args)
    result = clusters_api.delete_overlay(client, overlay_identifier=args.overlay_identifier)

    if args.raw:
        return result
    print(result["msg"])


@parser.command(
    argument("name", help="Overlay network name to join instance to.", type=str),
    argument("instance_id", help="Instance ID to add to overlay.", type=int),
    usage="vastai join overlay OVERLAY_NAME INSTANCE_ID",
    help="Adds instance to an overlay network",
    epilog=deindent("""
    Adds an instance to a compatible overlay network."""),
)
def join__overlay(args):
    """Add an instance to an overlay network."""
    if args.explain:
        print("request json:", {"name": args.name, "instance_id": args.instance_id})

    client = get_client(args)
    result = clusters_api.join_overlay(client, name=args.name, instance_id=args.instance_id)

    if args.raw:
        return result
    print(result["msg"])
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 198kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall