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 对象
更多
- 示例见 docs/examples.md
- 性能/交互优化分析见 docs/sdk-ux-performance-optimization.md
- 收尾记录见 docs/cleanup-0.2.0.md
- async 实施记录见 docs/async-client-implementation.md
- License: MIT
Project details
Release history Release notifications | RSS feed
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)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7cd7942a369ce7f58dfe879e86d53b6bcc620dde2d389c5a321f97315b2ed32a
|
|
| MD5 |
92057aec4edab365f9e04e4be9985cb7
|
|
| BLAKE2b-256 |
e76fa5b407b179a5e45f9184d3af35ffb8008f85e9f569182bdc1cb87ad13c9f
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b3da38f93e653301188d9421cd9bd9228734f9c17c1e5bb8164bcd345efc3025
|
|
| MD5 |
90697bd16438fe800b032af5e63fa46f
|
|
| BLAKE2b-256 |
12826294ea091a918bb93cbeaf8225fe03a8769e5b4a8a50907a1bc77048a701
|