aistation
AI Station 的非官方 Python SDK 和 CLI。
仍然需要vpn解决内网环境
安装
pip install ai-station-sdk
基础安装现在已经包含 CLI 运行所需依赖。
如果你想要更好的验证码终端渲染能力(Pillow):
pip install "ai-station-sdk[cli]"
CLI
CLI 可以查询状态,也支持 task/env 的创建、等待和删除辅助操作。
aistation login # 交互式登录
# or
# export AISTATION_ACCOUNT=your_account
# export AISTATION_PASSWORD='your_password'
# aistation login
aistation status
aistation gpus
aistation task list
aistation env list
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
Metadata
Release files for ai-station-sdk 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ai_station_sdk-0.3.0.tar.gz | 200.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ai_station_sdk-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 316.1 kB
Release files / ai_station_sdk-0.3.0.tar.gz
| Download URL | ai_station_sdk-0.3.0.tar.gz |
|---|---|
| Size | 200.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e951e4428d36f51c6a1a5c3a0328e93659258079f5f2324b581ca8b90eeedfc0
|
|
BLAKE2b-256 checksum How to use checksums |
4c17a1f33384ae105e37ee61394128b2711b070d5a6070f8aa4250de9c1bf751
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Release files / ai_station_sdk-0.3.0-py3-none-any.whl
| Download URL | ai_station_sdk-0.3.0-py3-none-any.whl |
|---|---|
| Size | 115.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
61bb76bebdabe12f16373a2d3a96e5104cfbe0bf52fc5f7428444b39e6566707
|
|
BLAKE2b-256 checksum How to use checksums |
62c195cd423c87777f8e68dfb073ca655de5f2214b1823fce41d7b54ec56e6d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|