Skip to main content

scnet-cli

SCNet 超算互联网平台 OpenAPI 命令行客户端(公有云 CLI 风格),覆盖平台全部 API: 作业、文件、容器、Notebook、桌面 VNC、用户资源(成员)、模型服务(LLM)。

安装

pip install scnet-cli                # 依赖 typer / rich / requests
scnet --version

快速上手

# 1. 配置 AK/SK(个人中心 → 访问控制 下载授权码)与模型服务 API Key(可选)
scnet configure

# 2. 登录(获取各区域 token,缓存于 ~/.scnet/cache/)
scnet auth login

# 3. 常用查询
scnet job stats                 # 当前作业数量(运行/排队/保留/挂起/其他)
scnet job list --status running # 运行中的作业
scnet job detail 36082          # 作业详情(实时结束自动回退历史)
scnet usage walltime            # 已用机时

多区域账号:scnet --cluster <clusterId> job list 或在 configure 时设默认区域。

命令总览

组 命令
configure configure / configure show —— 配置 AK/SK、默认区域、模型服务 API Key
auth login renew whoami regions —— token 获取/续约/校验、授权区域(hpcUrls 等)
cluster / queue cluster list(调度器 ID)、queue list(可访问队列)
job stats list detail history logs submit delete
usage walltime(机时)cores(核心数)storage(存储配额)
file ls upload(大文件自动分片)download mkdir touch rm mv cp rename exists preview permission share unshare check async-cp async-mv async-rm task task-cancel
container ls create start stop rm script spec detail url mounts resources groups images
notebook ls create start stop release rename detail url custom-start custom-url resources images model-images
desktop create ls rm url(VNC 会话)
member ls jobs add quota(团队成员/成员作业/配额)
llm models chat(流式/交互)ask(Responses)anthropic embed image video tts ocr ocr-rec doc-convert task task-cancel presign

全局选项:--profile -p、--output table|json -o、--cluster -c、--debug(打印等效 curl)。

示例

# 提交作业(命令行模式 / 脚本模式)
scnet job submit --name demo --queue debug --nodes 1 --ppn 4 --walltime 24:00:00 \
    --workdir /public/home/me/demo --cmd "python train.py"
scnet job submit --name slurm-job --queue debug --script /public/home/me/job.slurm --ppn 8

# 查看作业输出(自动定位 std.out,结束后按约定路径回退)
scnet job logs 36082
scnet job logs 36082 --err --trigger 2

# 上传/下载(>50MB 自动分片)
scnet file upload model.pt --to /public/home/me/
scnet file download /public/home/me/result.tar.gz --to ~/data/

# 大目录异步复制并跟踪任务
scnet file async-cp /public/home/me/dataset /public/home/me/backup
scnet file task <taskId>

# 模型服务(需 API Key;优先级 --api-key > 环境变量 SCNET_API_KEY > configure 保存值)
scnet llm models
scnet llm chat -m Qwen3.8-Max -p "用一句话介绍超算互联网"
scnet llm chat -m Qwen3.8-Max            # 交互模式
scnet llm image -m Qwen-Image-2.0 -p "一只橘猫" --size 1024x1024
scnet llm video -m Wan2.7-T2V -p "海边日落" --duration 5

认证与 token 说明(实现要点)

  • 平台功能:AK/SK 签名换 token(POST api.scnet.cn/api/user/v3/tokens, 签名 = HMAC-SHA256(SK, {"accessKey":…,"timestamp":…,"user":…}) 小写 hex,秒级时间戳)。 每个区域一个 token;clusterId=0/ac 为平台 token(认证/用户/成员/Notebook 创建启动), 其余为区域 token(作业 {hpcUrls}、文件 {efileUrls}、容器/Notebook {aiUrls},均取 enable=="true" 的 url)。
  • 仅实现 AK/SK 登录(已定决策):官方另有用户名密码换 token 端点 (POST www.scnet.cn/ac/openapi/v2/tokens,Header 带 user/password/orgId), 但 orgId 为线下颁发给第三方的标记码、官方也明确不推荐该方式,故不接入。
  • token 自动管理:JWT 内 expireTime 到期前自动续约(/tokens/next,过期超 24h 不可续约自动重新登录); 收到 10008 自动重登并重试一次。
  • 模型服务:Authorization: Bearer <API Key>(sk- 按量 / sk-tp- TokenPlan),与平台 token 无关。
  • 作业接口的「用户名」用 center 返回的 clusterUserInfo.userName,不是登录账号。

测试

cd scnet-cli
python -m unittest discover -s tests

目录

src/scnet/
├── signing.py   AK/SK 签名(对照官方算法)
├── config.py    ~/.scnet/ 多 profile 配置 + token 缓存(SCNET_HOME 可重定向)
├── client.py    API 客户端(全组端点、token 生命周期、10008 重试、envelope 解析)
├── output.py    作业状态映射(实时/历史两套枚举)、时长格式化
├── runtime.py   命令层共用(客户端构建、错误处理、table/json 输出分发)
└── commands/    12 个命令组
tests/           unittest(签名/配置/客户端纯函数/状态映射)

已知边界(对照离线文档实现的注意事项)

  • 本项目依据 ../openapi/(2026-10-18 抓取的官方文档快照)实现,未用真实 AK/SK 逐接口联调; --debug 可打印等效 curl,遇到字段出入请对照 openapi/api-doc/endpoints/<group>.json 与 openapi/orig-html/ 原始页面核对。
  • 文档个别接口参数风格混乱(如容器列表 GET 带 body、添加成员参数放 Header、merge 的 indentifier 拼写), 实现均按官方 curl 示例照抄,必要时加兜底。

Metadata

Release files for scnet-cli 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scnet-cli 0.2.0
File Size Uploaded Provenance Actions
scnet_cli-0.2.0.tar.gz 53.4 kB Without provenance Details for scnet_cli-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for scnet-cli 0.2.0
File Interpreter ABI Platform Actions
scnet_cli-0.2.0-py3-none-any.whl Python 3 none any Details for scnet_cli-0.2.0-py3-none-any.whl

Total release size: 108.2 kB

Release files / scnet_cli-0.2.0.tar.gz

Download URL scnet_cli-0.2.0.tar.gz
Size 53.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d8be3f5e8a03b255bcb0abe8f52d38014f88e770ff97e3b3f4a0a9c563370f1a
BLAKE2b-256 checksum
How to use checksums
385efd38c52e3f5309095effab65e10c3c36e5ec0764494a3042e5b4c47ad2a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release files / scnet_cli-0.2.0-py3-none-any.whl

Download URL scnet_cli-0.2.0-py3-none-any.whl
Size 54.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6cf22abde8440c8ad6a76badab492d05732d9f9704bb8d1717a90c21b2f1fe34
BLAKE2b-256 checksum
How to use checksums
4a3025e2e9ab252cff6b93133e91b949b4a530a6bd84aabb817943d69db55338
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Security for scnet-cli 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page