Skip to main content

Unofficial Python SDK for Westlake University AI Station

Project description

aistation

AI Station 的非官方 Python SDK 和 CLI。

仍然需要vpn解决内网环境

安装

pip install ai-station-sdk

如果你需要 CLI:

pip install "ai-station-sdk[cli]"

CLI

CLI 主要用来查询状态。

aistation login # 交互式登录

# or
# export AISTATION_ACCOUNT=your_account
# export AISTATION_PASSWORD='your_password'
# aistation login

aistation status
aistation gpus --free
aistation tasks

Python

import aistation as A

with A.AiStationClient() as client:
    spec = A.TaskSpec.gpu_hold(
        resource_group="8A100_80",
        image="pytorch/pytorch:21.10-py3",
        hours=2,
    )
    result = client.tasks.create_and_wait(spec)
    task = result.unwrap()
    pods = client.tasks.wait_pods(task)
    print(task.id, len(pods))

如果你只想恢复本地 token、不做自动登录:

import aistation as A

client = A.AiStationClient(auth_mode=A.AuthMode.TOKEN_ONLY)

如果你想显式控制请求遇到过期 token 时是否自动重登:

import aistation as A

client = A.AiStationClient(reauth_policy=A.ReauthPolicy.IF_POSSIBLE)

异步用法:

import aistation as A

async with A.AsyncAiStationClient() as client:
    spec = A.WorkPlatformSpec.notebook(
        resource_group="DEV-POOL",
        image="registry.example.invalid/ml/dev:latest",
    )
    wp = (await client.workplatforms.create(spec)).unwrap()
    print((await client.workplatforms.jupyter_url(wp)).get("url"))

高层 async helper:

import aistation as A
from aistation import aio

async with A.AsyncAiStationClient() as client:
    ctx = await aio.enumerate_form_context(client)
    groups = await aio.recommend.suggest_groups(client, card_type_contains="A100")
    print(len(ctx.images), len(groups))

创建类接口统一返回 OperationResult

import aistation as A

with A.AiStationClient() as client:
    result = client.tasks.create_and_wait(spec)
    task = result.unwrap()
    print(result.created, result.reused, result.waited, task.id)
    client.tasks.stop(task)  # 直接传 Task 对象

更多

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ai_station_sdk-0.2.0.tar.gz (187.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ai_station_sdk-0.2.0-py3-none-any.whl (105.0 kB view details)

Uploaded Python 3

File details

Details for the file ai_station_sdk-0.2.0.tar.gz.

File metadata

  • Download URL: ai_station_sdk-0.2.0.tar.gz
  • Upload date:
  • Size: 187.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for ai_station_sdk-0.2.0.tar.gz
Algorithm Hash digest
SHA256 7cd7942a369ce7f58dfe879e86d53b6bcc620dde2d389c5a321f97315b2ed32a
MD5 92057aec4edab365f9e04e4be9985cb7
BLAKE2b-256 e76fa5b407b179a5e45f9184d3af35ffb8008f85e9f569182bdc1cb87ad13c9f

See more details on using hashes here.

File details

Details for the file ai_station_sdk-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: ai_station_sdk-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 105.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for ai_station_sdk-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b3da38f93e653301188d9421cd9bd9228734f9c17c1e5bb8164bcd345efc3025
MD5 90697bd16438fe800b032af5e63fa46f
BLAKE2b-256 12826294ea091a918bb93cbeaf8225fe03a8769e5b4a8a50907a1bc77048a701

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page