compshare-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCompShare CLI
CompShare CLI
Manage CompShare GPU compute from the terminal with the command.
compshare通过命令从终端管理CompShare GPU计算资源。
compshareOperating rules
操作规则
- Use for automation. Parse the single JSON document instead of terminal tables.
compshare --json ... - Run before using an unfamiliar command or option. JSON help returns the current command, parameter and subcommand structure without requiring credentials.
compshare --json COMMAND --help - Put global options before the command group, for example .
compshare --json --profile production instance list --all - Inspect resources and prices before changing them. Use before a real create operation.
instance create --dry-run - Add only when the user has authorized the mutation. Deletion, stopping, reinstalling, resizing and similar operations can require confirmation.
--yes - Use explicit timeouts for creation, lifecycle waits and remote jobs. After a timeout, inspect the resource before retrying because the remote operation may still be running.
- Keep sensitive output redacted. Do not use unless the user explicitly needs the raw password, IP, access URL or login command.
--show-sensitive - Do not print, log or commit API credentials. Prefer an existing profile or environment variables over passing a private key on the command line.
- 自动化场景下使用。解析单个JSON文档而非终端表格。
compshare --json ... - 在使用不熟悉的命令或选项前,先执行。JSON格式的帮助会返回当前命令、参数和子命令结构,无需凭证。
compshare --json COMMAND --help - 将全局选项放在命令组之前,例如。
compshare --json --profile production instance list --all - 修改资源前先查看资源信息和价格。执行实际创建操作前,先使用。
instance create --dry-run - 仅在用户授权变更时添加。删除、停止、重装、调整规格等操作可能需要确认。
--yes - 为创建、生命周期等待和远程任务设置明确的超时时间。超时后,先检查资源状态再重试,因为远程操作可能仍在运行。
- 对敏感输出进行脱敏处理。除非用户明确需要原始密码、IP、访问URL或登录命令,否则不要使用。
--show-sensitive - 不要打印、记录或提交API凭证。优先使用现有配置文件或环境变量,而非在命令行中传递私钥。
Install and configure
安装与配置
bash
pip install compshare-cli
pip install --upgrade compshare-cliConfigure a credential profile interactively:
bash
compshare config --name default
compshare config list
compshare --json doctorFor non-interactive environments, provide credentials through the process environment:
bash
export COMPSHARE_PUBLIC_KEY='...'
export COMPSHARE_PRIVATE_KEY='...'
compshare --json doctorSelect a named profile with . Use to locate the configuration file and to change the default profile.
--profile NAMEcompshare config pathcompshare config use NAMEbash
pip install compshare-cli
pip install --upgrade compshare-cli交互式配置凭证配置文件:
bash
compshare config --name default
compshare config list
compshare --json doctor在非交互式环境中,通过进程环境提供凭证:
bash
export COMPSHARE_PUBLIC_KEY='...'
export COMPSHARE_PRIVATE_KEY='...'
compshare --json doctor使用选择指定的配置文件。使用查找配置文件位置,使用更改默认配置文件。
--profile NAMEcompshare config pathcompshare config use NAMEDiscover current commands
查看当前命令
Prefer the CLI's structured help over guessing flags:
bash
compshare --json --help
compshare --json instance --help
compshare --json instance create --help
compshare --json image list --helpGlobal options:
- : emit the stable machine-readable response envelope.
--json - : select a credential profile.
--profile NAME - : select the output language; JSON error codes remain language-independent.
--lang zh|en - : reveal normally redacted fields; avoid by default.
--show-sensitive - : print the CLI version.
--version
优先使用CLI的结构化帮助而非猜测参数:
bash
compshare --json --help
compshare --json instance --help
compshare --json instance create --help
compshare --json image list --help全局选项:
- :输出稳定的机器可读响应包。
--json - :选择凭证配置文件。
--profile NAME - :选择输出语言;JSON错误码保持独立于语言。
--lang zh|en - :显示通常会被脱敏的字段;默认避免使用。
--show-sensitive - :打印CLI版本。
--version
Create an instance
创建实例
Discover locations and images, then search legal specifications and real inventory:
bash
compshare --json instance zones
compshare --json image list \
--source platform \
--region cn-sh2 \
--zone cn-sh2-02 \
--all
compshare --json instance search \
--region cn-sh2 \
--zone cn-sh2-02 \
--gpu 4090 \
--image IMAGE_ID \
--available--imageinstance searchBuild and inspect the create plan without changing resources:
bash
compshare --json instance create \
--region cn-sh2 \
--zone cn-sh2-02 \
--gpu 4090 \
--count 1 \
--cpu 16 \
--memory 64GiB \
--image IMAGE_ID \
--image-source platform \
--disk 100GiB \
--charge Postpay \
--max-count 1 \
--max-price 20 \
--dry-runReview the returned selection, capacity, price and request. If the user approves it, rerun without and add plus an explicit timeout:
--dry-run--yesbash
compshare --json instance create \
--region cn-sh2 \
--zone cn-sh2-02 \
--gpu 4090 \
--count 1 \
--cpu 16 \
--memory 64GiB \
--image IMAGE_ID \
--image-source platform \
--disk 100GiB \
--charge Postpay \
--max-count 1 \
--max-price 20 \
--yes \
--timeout 900In JSON mode, creation cannot open the interactive wizard. Supply , , , , , and . Here is GPUs per instance; is the number of instances.
--gpu--count--cpu--memory--image--region--zone--count--max-count先查看可用区域和镜像,再搜索合法规格和实际库存:
bash
compshare --json instance zones
compshare --json image list \
--source platform \
--region cn-sh2 \
--zone cn-sh2-02 \
--all
compshare --json instance search \
--region cn-sh2 \
--zone cn-sh2-02 \
--gpu 4090 \
--image IMAGE_ID \
--available--imageinstance search无需修改资源即可生成并查看创建计划:
bash
compshare --json instance create \
--region cn-sh2 \
--zone cn-sh2-02 \
--gpu 4090 \
--count 1 \
--cpu 16 \
--memory 64GiB \
--image IMAGE_ID \
--image-source platform \
--disk 100GiB \
--charge Postpay \
--max-count 1 \
--max-price 20 \
--dry-run查看返回的选型、容量、价格和请求信息。如果用户批准,去掉并添加以及明确的超时时间后重新运行:
--dry-run--yesbash
compshare --json instance create \
--region cn-sh2 \
--zone cn-sh2-02 \
--gpu 4090 \
--count 1 \
--cpu 16 \
--memory 64GiB \
--image IMAGE_ID \
--image-source platform \
--disk 100GiB \
--charge Postpay \
--max-count 1 \
--max-price 20 \
--yes \
--timeout 900在JSON模式下,创建操作无法打开交互式向导。需提供、、、、、和参数。此处指每个实例的GPU数量;指实例的数量。
--gpu--count--cpu--memory--image--region--zone--count--max-countInspect and manage instances
查看与管理实例
bash
undefinedbash
undefinedList and filter
列出并过滤实例
compshare --json instance list --all
compshare --json instance list --status Running --gpu 4090 --all
compshare --json instance list --all
compshare --json instance list --status Running --gpu 4090 --all
Show a full record or selected sections
查看完整记录或指定部分
compshare --json instance show INSTANCE_ID
compshare --json instance show INSTANCE_ID --status --spec --billing
compshare --json instance show INSTANCE_ID
compshare --json instance show INSTANCE_ID --status --spec --billing
Batch lifecycle operations
批量生命周期操作
compshare --json instance start INSTANCE_1 INSTANCE_2 --timeout 600
compshare --json instance stop INSTANCE_1 INSTANCE_2 --yes --timeout 600
compshare --json instance wait INSTANCE_1 INSTANCE_2 --state Running --timeout 600
compshare --json instance start INSTANCE_1 INSTANCE_2 --timeout 600
compshare --json instance stop INSTANCE_1 INSTANCE_2 --yes --timeout 600
compshare --json instance wait INSTANCE_1 INSTANCE_2 --state Running --timeout 600
Permanently delete; add --release-disk only when attached data disks must also be deleted
永久删除;仅当需要同时删除挂载的数据盘时添加--release-disk
compshare --json instance delete INSTANCE_ID --yes --timeout 600
Use the direct instance ID commands without guessing a Region or Zone; the CLI resolves the location. Batch operations report succeeded and failed instances separately and exit nonzero on partial failure.
Other instance workflows are available under:
```text
instance rename, password, reinstall, resize
instance price, resize-price, billing, refund, charge
instance network, models, ports, schedule, software, templateInspect each workflow with before invoking it.
compshare --json instance COMMAND --helpcompshare --json instance delete INSTANCE_ID --yes --timeout 600
直接使用实例ID命令,无需猜测Region或Zone;CLI会自动解析位置。批量操作会分别报告成功和失败的实例,若部分失败则返回非零退出码。
其他实例工作流可通过以下命令访问:
```text
instance rename, password, reinstall, resize
instance price, resize-price, billing, refund, charge
instance network, models, ports, schedule, software, template调用前先通过查看每个工作流的详情。
compshare --json instance COMMAND --helpSSH and file transfer
SSH与文件传输
Use for an interactive shell or a short synchronous command:
instance sshbash
compshare instance ssh INSTANCE_ID
compshare --json instance ssh INSTANCE_ID -- nvidia-smi
compshare --json instance ssh INSTANCE_ID -- sh -lc 'cd /workspace && python train.py'Always place remote command arguments after so the CLI does not parse them as local options. Use only when the remote command needs shell syntax such as pipes, redirects, or variable expansion.
--sh -lc&&Copy a file or directory by prefixing the remote path with :
:bash
compshare --json instance cp INSTANCE_ID ./model.bin :/workspace/model.bin
compshare --json instance cp INSTANCE_ID ./dataset :/workspace/dataset
compshare --json instance cp INSTANCE_ID :/workspace/results ./resultsThe CLI automatically resolves and caches SSH connection data. Use after a password reset or reinstall, and when cached connection data must not be used.
--refresh--no-cache使用获取交互式shell或执行短期同步命令:
instance sshbash
compshare instance ssh INSTANCE_ID
compshare --json instance ssh INSTANCE_ID -- nvidia-smi
compshare --json instance ssh INSTANCE_ID -- sh -lc 'cd /workspace && python train.py'务必将远程命令参数放在之后,避免CLI将其解析为本地选项。仅当远程命令需要shell语法(如管道、重定向、或变量扩展)时,才使用。
--&&sh -lc通过在远程路径前添加来复制文件或目录:
:bash
compshare --json instance cp INSTANCE_ID ./model.bin :/workspace/model.bin
compshare --json instance cp INSTANCE_ID ./dataset :/workspace/dataset
compshare --json instance cp INSTANCE_ID :/workspace/results ./resultsCLI会自动解析并缓存SSH连接数据。重置密码或重装系统后使用,当不能使用缓存的连接数据时使用。
--refresh--no-cacheDurable remote jobs
持久化远程任务
Use for installation, training, compilation and other work that must survive a local terminal or network disconnect:
instance jobbash
compshare --json instance job submit INSTANCE_ID \
--name training \
--cwd /workspace/project \
-- python train.py --epochs 100
compshare --json instance job list INSTANCE_ID
compshare --json instance job show INSTANCE_ID JOB_ID
compshare --json instance job logs INSTANCE_ID JOB_ID --tail 200
compshare --json instance job wait INSTANCE_ID JOB_ID --timeout 3600Use for live logs. For incremental agent reads, use byte offsets from the previous JSON response:
--followbash
compshare --json instance job logs INSTANCE_ID JOB_ID \
--stdout-offset STDOUT_OFFSET \
--stderr-offset STDERR_OFFSET \
--limit 65536Cancel or prune jobs only when authorized:
bash
compshare --json instance job cancel INSTANCE_ID JOB_ID --yes
compshare --json instance job prune INSTANCE_ID --older-than 7d --yesA job wait timeout does not cancel the remote job. Query its state before submitting replacement work.
对于安装、训练、编译等需要在本地终端或网络断开后仍能继续运行的工作,使用:
instance jobbash
compshare --json instance job submit INSTANCE_ID \
--name training \
--cwd /workspace/project \
-- python train.py --epochs 100
compshare --json instance job list INSTANCE_ID
compshare --json instance job show INSTANCE_ID JOB_ID
compshare --json instance job logs INSTANCE_ID JOB_ID --tail 200
compshare --json instance job wait INSTANCE_ID JOB_ID --timeout 3600使用查看实时日志。对于增量代理读取,使用上一次JSON响应中的字节偏移量:
--followbash
compshare --json instance job logs INSTANCE_ID JOB_ID \
--stdout-offset STDOUT_OFFSET \
--stderr-offset STDERR_OFFSET \
--limit 65536仅在获得授权时取消或清理任务:
bash
compshare --json instance job cancel INSTANCE_ID JOB_ID --yes
compshare --json instance job prune INSTANCE_ID --older-than 7d --yes任务等待超时不会取消远程任务。提交替代任务前先查询其状态。
Images, storage and teams
镜像、存储与团队
Discover subcommands first, then inspect the exact operation:
bash
compshare --json image --help
compshare --json storage --help
compshare --json storage disk --help
compshare --json team --helpCommon entry points:
text
image list/show/create/progress/update/delete/share/unshare/publish
storage disk list/create/attach/detach/price/resize/delete
storage us3 attach
team list/joined/show/create/update/delete/audit
team invite/member/quota/billingTreat image deletion, disk deletion, disk detach/resize, quota changes and team mutations as state-changing operations. Read the current resource and request confirmation before adding where supported.
--yes先查看子命令,再了解具体操作:
bash
compshare --json image --help
compshare --json storage --help
compshare --json storage disk --help
compshare --json team --help常见入口:
text
image list/show/create/progress/update/delete/share/unshare/publish
storage disk list/create/attach/detach/price/resize/delete
storage us3 attach
team list/joined/show/create/update/delete/audit
team invite/member/quota/billing将镜像删除、磁盘删除、磁盘挂载/卸载/调整规格、配额变更和团队变更视为状态变更操作。在支持添加的场景下,先查看当前资源状态并请求确认。
--yesProduct questions and diagnostics
产品咨询与诊断
bash
compshare --json ask '按量实例关机以后,云硬盘还收费吗?'
compshare --json doctor
compshare feedback bug '创建实例时发生错误'Use for CompShare product usage and billing questions. Use for local configuration, authentication, network and SSH environment checks. Use only when the user asks to send feedback; it performs an external write.
askdoctorfeedbackbash
compshare --json ask '按量实例关机以后,云硬盘还收费吗?'
compshare --json doctor
compshare feedback bug '创建实例时发生错误'使用咨询CompShare产品使用和账单相关问题。使用检查本地配置、认证、网络和SSH环境。仅当用户要求发送反馈时使用;该操作会执行外部写入。
askdoctorfeedbackJSON contract
JSON协议
Successful commands return one UTF-8 JSON document shaped like:
json
{
"ok": true,
"schema_version": "1",
"data": {}
}Failures return with a stable , a human-readable and optional . List commands place rows in and pagination or API metadata in . Check the process exit code as well as ; batch operations can fail partially.
ok: falseerror.codeerror.messageerror.detailsdata.itemsmetaok成功的命令会返回一个UTF-8格式的JSON文档,结构如下:
json
{
"ok": true,
"schema_version": "1",
"data": {}
}失败时返回,包含稳定的、易读的和可选的。列表命令会将行数据放在中,分页或API元数据放在中。除了检查字段,还要检查进程退出码;批量操作可能部分失败。
ok: falseerror.codeerror.messageerror.detailsdata.itemsmetaokTroubleshooting
故障排查
- Authentication or configuration failure: run , then inspect
compshare --json doctorwithout exposing credential values.compshare config list - No available specification: search again with the exact image and ; relax GPU, Region, Zone, CPU, memory, billing or disk constraints deliberately.
--available - JSON creation asks for interaction: provide all seven required automation options listed in the create section.
- SSH option parsed by the CLI: insert before the remote command.
-- - Long SSH command interrupted: resubmit it as an rather than retrying synchronously.
instance job - Lifecycle or job timeout: inspect current state before retrying; do not assume the remote operation stopped.
- Unexpected option or output: query and follow the installed version rather than this reference.
compshare --json COMMAND --help
- 认证或配置失败:执行,然后查看
compshare --json doctor,注意不要暴露凭证信息。compshare config list - 无可用规格:使用精确镜像和重新搜索;有针对性地放宽GPU、Region、Zone、CPU、内存、计费方式或磁盘限制。
--available - JSON模式创建请求交互:提供创建部分列出的所有七个必填自动化选项。
- SSH选项被CLI解析:在远程命令前插入。
-- - 长SSH命令中断:将其重新提交为而非同步重试。
instance job - 生命周期或任务超时:重试前先检查当前状态;不要假设远程操作已停止。
- 意外选项或输出:查询,以已安装版本的帮助为准,而非此参考文档。
compshare --json COMMAND --help