compshare-cli 0.1.3__tar.gz → 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. compshare_cli-0.3.0/LICENSE +201 -0
  2. compshare_cli-0.3.0/PKG-INFO +235 -0
  3. compshare_cli-0.3.0/README.md +210 -0
  4. {compshare_cli-0.1.3 → compshare_cli-0.3.0}/pyproject.toml +12 -3
  5. {compshare_cli-0.1.3 → compshare_cli-0.3.0}/src/compshare_cli/__init__.py +1 -1
  6. {compshare_cli-0.1.3 → compshare_cli-0.3.0}/src/compshare_cli/actions.py +27 -1
  7. compshare_cli-0.3.0/src/compshare_cli/api.py +240 -0
  8. {compshare_cli-0.1.3 → compshare_cli-0.3.0}/src/compshare_cli/cli.py +96 -15
  9. compshare_cli-0.3.0/src/compshare_cli/commands/ask.py +31 -0
  10. {compshare_cli-0.1.3 → compshare_cli-0.3.0}/src/compshare_cli/commands/common.py +8 -9
  11. compshare_cli-0.3.0/src/compshare_cli/commands/doctor.py +124 -0
  12. compshare_cli-0.3.0/src/compshare_cli/commands/feedback.py +20 -0
  13. {compshare_cli-0.1.3 → compshare_cli-0.3.0}/src/compshare_cli/commands/image.py +66 -45
  14. {compshare_cli-0.1.3 → compshare_cli-0.3.0}/src/compshare_cli/commands/instance.py +536 -153
  15. {compshare_cli-0.1.3 → compshare_cli-0.3.0}/src/compshare_cli/commands/storage.py +25 -20
  16. compshare_cli-0.3.0/src/compshare_cli/commands/team.py +651 -0
  17. {compshare_cli-0.1.3 → compshare_cli-0.3.0}/src/compshare_cli/config.py +52 -15
  18. {compshare_cli-0.1.3 → compshare_cli-0.3.0}/src/compshare_cli/i18n.py +209 -12
  19. compshare_cli-0.3.0/src/compshare_cli/insights.py +146 -0
  20. compshare_cli-0.3.0/src/compshare_cli/location.py +85 -0
  21. {compshare_cli-0.1.3 → compshare_cli-0.3.0}/src/compshare_cli/output.py +63 -16
  22. {compshare_cli-0.1.3 → compshare_cli-0.3.0}/src/compshare_cli/parsing.py +40 -1
  23. compshare_cli-0.3.0/src/compshare_cli/qa.py +51 -0
  24. compshare_cli-0.3.0/src/compshare_cli/runtime.py +20 -0
  25. compshare_cli-0.3.0/src/compshare_cli/sdk.py +68 -0
  26. compshare_cli-0.3.0/src/compshare_cli/ssh.py +250 -0
  27. compshare_cli-0.3.0/src/compshare_cli.egg-info/PKG-INFO +235 -0
  28. {compshare_cli-0.1.3 → compshare_cli-0.3.0}/src/compshare_cli.egg-info/SOURCES.txt +13 -1
  29. {compshare_cli-0.1.3 → compshare_cli-0.3.0}/src/compshare_cli.egg-info/entry_points.txt +1 -0
  30. {compshare_cli-0.1.3 → compshare_cli-0.3.0}/src/compshare_cli.egg-info/requires.txt +3 -0
  31. {compshare_cli-0.1.3 → compshare_cli-0.3.0}/tests/test_actions.py +13 -3
  32. compshare_cli-0.3.0/tests/test_api.py +104 -0
  33. compshare_cli-0.3.0/tests/test_cli.py +1465 -0
  34. {compshare_cli-0.1.3 → compshare_cli-0.3.0}/tests/test_config.py +39 -14
  35. compshare_cli-0.3.0/tests/test_feedback.py +154 -0
  36. compshare_cli-0.3.0/tests/test_location.py +103 -0
  37. compshare_cli-0.3.0/tests/test_output.py +61 -0
  38. {compshare_cli-0.1.3 → compshare_cli-0.3.0}/tests/test_parsing.py +30 -1
  39. compshare_cli-0.3.0/tests/test_qa.py +121 -0
  40. compshare_cli-0.3.0/tests/test_sdk.py +99 -0
  41. compshare_cli-0.3.0/tests/test_ssh.py +209 -0
  42. compshare_cli-0.1.3/PKG-INFO +0 -284
  43. compshare_cli-0.1.3/README.md +0 -266
  44. compshare_cli-0.1.3/src/compshare_cli/api.py +0 -127
  45. compshare_cli-0.1.3/src/compshare_cli/location.py +0 -91
  46. compshare_cli-0.1.3/src/compshare_cli/runtime.py +0 -34
  47. compshare_cli-0.1.3/src/compshare_cli/sdk.py +0 -27
  48. compshare_cli-0.1.3/src/compshare_cli.egg-info/PKG-INFO +0 -284
  49. compshare_cli-0.1.3/tests/test_cli.py +0 -585
  50. compshare_cli-0.1.3/tests/test_location.py +0 -33
  51. compshare_cli-0.1.3/tests/test_output.py +0 -22
  52. compshare_cli-0.1.3/tests/test_sdk.py +0 -38
  53. {compshare_cli-0.1.3 → compshare_cli-0.3.0}/setup.cfg +0 -0
  54. {compshare_cli-0.1.3 → compshare_cli-0.3.0}/src/compshare_cli/__main__.py +0 -0
  55. {compshare_cli-0.1.3 → compshare_cli-0.3.0}/src/compshare_cli/commands/__init__.py +0 -0
  56. {compshare_cli-0.1.3 → compshare_cli-0.3.0}/src/compshare_cli/errors.py +0 -0
  57. {compshare_cli-0.1.3 → compshare_cli-0.3.0}/src/compshare_cli.egg-info/dependency_links.txt +0 -0
  58. {compshare_cli-0.1.3 → compshare_cli-0.3.0}/src/compshare_cli.egg-info/top_level.txt +0 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,235 @@
1
+ Metadata-Version: 2.4
2
+ Name: compshare-cli
3
+ Version: 0.3.0
4
+ Summary: Command-line client for CompShare GPU compute
5
+ Author: CompShare
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/BennielAllan/compshare-cli
8
+ Project-URL: Repository, https://github.com/BennielAllan/compshare-cli
9
+ Project-URL: Changelog, https://github.com/BennielAllan/compshare-cli/blob/master/CHANGELOG.md
10
+ Project-URL: Issues, https://github.com/BennielAllan/compshare-cli/issues
11
+ Requires-Python: >=3.9
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: click<9,>=8.1
15
+ Requires-Dist: pexpect<5,>=4.9; platform_system != "Windows"
16
+ Requires-Dist: rich<15,>=13
17
+ Requires-Dist: typer<1,>=0.12
18
+ Requires-Dist: ucloud-sdk-python3<0.12,>=0.11.103
19
+ Requires-Dist: urllib3<2,>=1.26.18; python_version < "3.10" and platform_system == "Darwin"
20
+ Provides-Extra: dev
21
+ Requires-Dist: pytest<10,>=8; extra == "dev"
22
+ Requires-Dist: pytest-cov<8,>=5; extra == "dev"
23
+ Requires-Dist: ruff<1,>=0.6; extra == "dev"
24
+ Dynamic: license-file
25
+
26
+ # CompShare CLI
27
+
28
+ 在终端管理优云智算 GPU 实例、镜像、云盘、US3 挂载和团队资源。
29
+
30
+ - 交互式创建实例,实时查询规格、库存和价格
31
+ - 支持批量生命周期操作、等待状态和跨地域查询
32
+ - 支持社区/自定义镜像、云盘、团队额度与账单
33
+ - 默认中文帮助,可切换英文;所有命令支持 JSON 输出
34
+ - 可通过 `compshare ask` 查询产品使用和计费知识
35
+ - 可通过 `compshare feedback` 反馈 CLI 问题和建议
36
+ - 基于官方 [`ucloud-sdk-python3`](https://github.com/ucloud/ucloud-sdk-python3)
37
+
38
+ 当前版本:`0.3.0`,要求 Python 3.9 或更高版本。
39
+
40
+ ## 安装
41
+
42
+ ```bash
43
+ pip install compshare-cli
44
+ compshare -h
45
+ ```
46
+
47
+ 本地开发:
48
+
49
+ ```bash
50
+ git clone https://github.com/BennielAllan/compshare-cli.git
51
+ cd compshare-cli
52
+ python -m venv .venv
53
+ source .venv/bin/activate
54
+ python -m pip install -e '.[dev]'
55
+ ```
56
+
57
+ Windows 激活虚拟环境时使用:
58
+
59
+ ```powershell
60
+ .\.venv\Scripts\Activate.ps1
61
+ ```
62
+
63
+ ## 配置
64
+
65
+ ```bash
66
+ compshare config --name default
67
+ ```
68
+
69
+ 凭证保存在 `~/.config/compshare/config.json`,支持多个配置:
70
+
71
+ ```bash
72
+ compshare config list
73
+ compshare config use production
74
+ compshare --profile production instance list
75
+ ```
76
+
77
+ 也可以使用环境变量:
78
+
79
+ ```bash
80
+ export COMPSHARE_PUBLIC_KEY='...'
81
+ export COMPSHARE_PRIVATE_KEY='...'
82
+ ```
83
+
84
+ ## 快速开始
85
+
86
+ ```bash
87
+ # 查规格、库存和实例
88
+ compshare instance search --region cn-sh2 --zone cn-sh2-02
89
+ compshare instance search --region cn-sh2 --zone cn-sh2-02 \
90
+ --gpu 4090 --image IMAGE_ID --available
91
+ compshare instance list --all
92
+
93
+ # 交互式创建
94
+ compshare instance create
95
+
96
+ # 批量操作与等待
97
+ compshare instance stop INSTANCE_1 INSTANCE_2
98
+ compshare instance start INSTANCE_1 INSTANCE_2
99
+ compshare instance wait INSTANCE_1 INSTANCE_2 --state Running
100
+
101
+ # SSH
102
+ compshare instance ssh INSTANCE_ID
103
+ # 默认自动填写 API 返回的密码;需要手动输入时可关闭
104
+ compshare instance ssh INSTANCE_ID --no-auto-password
105
+ # 自动登录后执行远程命令;远程参数用 -- 与 CLI 选项分隔
106
+ compshare instance ssh INSTANCE_ID -- nvidia-smi --query-gpu=name
107
+ compshare instance ssh INSTANCE_ID -- 'cd /workspace && python train.py'
108
+ # 上传本地文件或目录,目录会自动递归复制
109
+ compshare instance scp INSTANCE_ID ./model.bin /workspace/model.bin
110
+ compshare instance scp INSTANCE_ID ./dataset /workspace/dataset
111
+
112
+ # 产品问答
113
+ compshare ask "按量实例关机以后,云硬盘还收费吗?"
114
+ ```
115
+
116
+ 自动化创建示例:
117
+
118
+ ```bash
119
+ compshare instance create \
120
+ --region cn-sh2 \
121
+ --zone cn-sh2-02 \
122
+ --gpu 4090 \
123
+ --count 1 \
124
+ --cpu 16 \
125
+ --memory 64GiB \
126
+ --image IMAGE_ID \
127
+ --disk 100GiB \
128
+ --charge Postpay \
129
+ --max-price 20 \
130
+ --yes
131
+ ```
132
+
133
+ 使用 `--dry-run` 只检查库存、价格和请求,不创建资源。
134
+
135
+ ## 功能入口
136
+
137
+ ```text
138
+ compshare instance GPU 实例、规格、库存、价格和生命周期
139
+ compshare image 平台、自定义、社区及共享镜像
140
+ compshare storage 云盘和 US3 挂载
141
+ compshare team 团队、邀请、成员额度、账单和审计
142
+ compshare doctor 配置、鉴权、网络与 SSH 环境诊断
143
+ compshare ask 产品使用和计费问答
144
+ compshare feedback 反馈 CLI 问题或建议
145
+ ```
146
+
147
+ ## 产品问答
148
+
149
+ ```bash
150
+ compshare ask "按量实例关机以后,云硬盘还收费吗?"
151
+ compshare --json ask "如何创建自定义镜像?"
152
+ ```
153
+
154
+ 普通输出显示答案和引用资料标题;`--json` 返回完整的答案、引用、请求 ID 和检索元数据。
155
+ 命令只向内置问答服务发送 `question` 字段,不会附带 API 凭证、配置文件或其他命令上下文。
156
+
157
+ ## 反馈
158
+
159
+ ```bash
160
+ compshare feedback bug "创建实例时发生错误"
161
+ compshare feedback suggest "希望支持保存默认创建规格"
162
+ ```
163
+
164
+ 反馈会直接发送到内置的 CompShare Insights 服务地址。开发环境可使用
165
+ `COMPSHARE_INSIGHTS_URL=http://127.0.0.1:18080` 覆盖服务地址。
166
+
167
+ CLI 会异步统计指令使用情况,且仅发送指令名称、CLI 版本、操作系统和发生时间;不会发送
168
+ 命令参数、凭证、资源 ID 或命令输出。
169
+
170
+ 查看完整命令和参数:
171
+
172
+ ```bash
173
+ compshare -h
174
+ compshare instance -h
175
+ compshare instance create -h
176
+ ```
177
+
178
+ ## 脚本调用
179
+
180
+ `--json`、`--profile` 和 `--show-sensitive` 是全局选项,必须放在子命令前:
181
+
182
+ ```bash
183
+ compshare --json instance list --status Running --all
184
+ compshare --profile production image list --source community --region cn-sh2 --zone cn-sh2-02
185
+ compshare --json --show-sensitive instance show uhost-xxxxxxxx
186
+ ```
187
+
188
+ JSON 模式不会启动交互向导。生命周期操作可使用 `--wait`、`--no-wait` 和
189
+ `--timeout` 控制等待行为;部分批量操作失败时,CLI 返回非零退出码。默认输出会递归隐藏
190
+ 密码、IP、访问 URL 和登录命令;只有显式指定 `--show-sensitive` 才会输出原值。
191
+
192
+ Region 和 Zone 是资源参数,放在对应子命令后:
193
+
194
+ ```bash
195
+ compshare instance list --region cn-sh2
196
+ compshare instance create --region cn-sh2 --zone cn-sh2-02
197
+ compshare image list --source custom --region cn-sh2 --zone cn-sh2-02
198
+ ```
199
+
200
+ CLI 不保存或自动注入默认 Region/Zone。非交互式地域资源操作需要显式传入;按实例 ID
201
+ 执行的生命周期操作使用 `DescribeCompShareInstance` 响应中的 Region 和 Zone;响应缺少任一
202
+ 字段时会停止操作,不会从 Zone 推导或用请求 Region 补齐。
203
+
204
+ ## 语言
205
+
206
+ ```bash
207
+ compshare lang en
208
+ compshare lang zh
209
+ compshare lang # 查看当前语言
210
+ ```
211
+
212
+ 也可以通过 `COMPSHARE_LANG=en` 临时覆盖。
213
+
214
+ ## 安全说明
215
+
216
+ - 配置目录和文件分别使用 `0700`、`0600` 权限。
217
+ - API 私钥不会出现在命令输出中。
218
+ - 默认使用 `***` 隐藏密码、私钥、IP、访问 URL、令牌和登录命令,包括嵌套 JSON 字段。
219
+ - `instance ssh` 在支持的交互式终端中通过伪终端自动填写登录密码,不会打印密码或将其放入进程参数。
220
+ - 自动登录会接受首次出现的 SSH 主机密钥;已记录主机的密钥发生变化时仍会拒绝连接。
221
+ - `instance ssh INSTANCE_ID -- COMMAND` 可非交互执行远程命令,透传命令输出和退出码。
222
+ - `instance scp INSTANCE_ID LOCAL_PATH REMOTE_PATH` 可自动认证并上传本地文件或目录。
223
+ - `--show-sensitive` 会恢复这些字段的原始值;请勿在共享终端、CI 日志或 Agent 会话中使用。
224
+ - 删除、关机、重启、重装和改配等操作默认要求确认。
225
+
226
+ ## 开发校验
227
+
228
+ ```bash
229
+ ruff check .
230
+ ruff format --check .
231
+ pytest
232
+ ```
233
+
234
+ 公开 API 覆盖范围和版本变化见 [CHANGELOG.md](CHANGELOG.md),维护者发布流程见
235
+ [RELEASING.md](RELEASING.md)。
@@ -0,0 +1,210 @@
1
+ # CompShare CLI
2
+
3
+ 在终端管理优云智算 GPU 实例、镜像、云盘、US3 挂载和团队资源。
4
+
5
+ - 交互式创建实例,实时查询规格、库存和价格
6
+ - 支持批量生命周期操作、等待状态和跨地域查询
7
+ - 支持社区/自定义镜像、云盘、团队额度与账单
8
+ - 默认中文帮助,可切换英文;所有命令支持 JSON 输出
9
+ - 可通过 `compshare ask` 查询产品使用和计费知识
10
+ - 可通过 `compshare feedback` 反馈 CLI 问题和建议
11
+ - 基于官方 [`ucloud-sdk-python3`](https://github.com/ucloud/ucloud-sdk-python3)
12
+
13
+ 当前版本:`0.3.0`,要求 Python 3.9 或更高版本。
14
+
15
+ ## 安装
16
+
17
+ ```bash
18
+ pip install compshare-cli
19
+ compshare -h
20
+ ```
21
+
22
+ 本地开发:
23
+
24
+ ```bash
25
+ git clone https://github.com/BennielAllan/compshare-cli.git
26
+ cd compshare-cli
27
+ python -m venv .venv
28
+ source .venv/bin/activate
29
+ python -m pip install -e '.[dev]'
30
+ ```
31
+
32
+ Windows 激活虚拟环境时使用:
33
+
34
+ ```powershell
35
+ .\.venv\Scripts\Activate.ps1
36
+ ```
37
+
38
+ ## 配置
39
+
40
+ ```bash
41
+ compshare config --name default
42
+ ```
43
+
44
+ 凭证保存在 `~/.config/compshare/config.json`,支持多个配置:
45
+
46
+ ```bash
47
+ compshare config list
48
+ compshare config use production
49
+ compshare --profile production instance list
50
+ ```
51
+
52
+ 也可以使用环境变量:
53
+
54
+ ```bash
55
+ export COMPSHARE_PUBLIC_KEY='...'
56
+ export COMPSHARE_PRIVATE_KEY='...'
57
+ ```
58
+
59
+ ## 快速开始
60
+
61
+ ```bash
62
+ # 查规格、库存和实例
63
+ compshare instance search --region cn-sh2 --zone cn-sh2-02
64
+ compshare instance search --region cn-sh2 --zone cn-sh2-02 \
65
+ --gpu 4090 --image IMAGE_ID --available
66
+ compshare instance list --all
67
+
68
+ # 交互式创建
69
+ compshare instance create
70
+
71
+ # 批量操作与等待
72
+ compshare instance stop INSTANCE_1 INSTANCE_2
73
+ compshare instance start INSTANCE_1 INSTANCE_2
74
+ compshare instance wait INSTANCE_1 INSTANCE_2 --state Running
75
+
76
+ # SSH
77
+ compshare instance ssh INSTANCE_ID
78
+ # 默认自动填写 API 返回的密码;需要手动输入时可关闭
79
+ compshare instance ssh INSTANCE_ID --no-auto-password
80
+ # 自动登录后执行远程命令;远程参数用 -- 与 CLI 选项分隔
81
+ compshare instance ssh INSTANCE_ID -- nvidia-smi --query-gpu=name
82
+ compshare instance ssh INSTANCE_ID -- 'cd /workspace && python train.py'
83
+ # 上传本地文件或目录,目录会自动递归复制
84
+ compshare instance scp INSTANCE_ID ./model.bin /workspace/model.bin
85
+ compshare instance scp INSTANCE_ID ./dataset /workspace/dataset
86
+
87
+ # 产品问答
88
+ compshare ask "按量实例关机以后,云硬盘还收费吗?"
89
+ ```
90
+
91
+ 自动化创建示例:
92
+
93
+ ```bash
94
+ compshare instance create \
95
+ --region cn-sh2 \
96
+ --zone cn-sh2-02 \
97
+ --gpu 4090 \
98
+ --count 1 \
99
+ --cpu 16 \
100
+ --memory 64GiB \
101
+ --image IMAGE_ID \
102
+ --disk 100GiB \
103
+ --charge Postpay \
104
+ --max-price 20 \
105
+ --yes
106
+ ```
107
+
108
+ 使用 `--dry-run` 只检查库存、价格和请求,不创建资源。
109
+
110
+ ## 功能入口
111
+
112
+ ```text
113
+ compshare instance GPU 实例、规格、库存、价格和生命周期
114
+ compshare image 平台、自定义、社区及共享镜像
115
+ compshare storage 云盘和 US3 挂载
116
+ compshare team 团队、邀请、成员额度、账单和审计
117
+ compshare doctor 配置、鉴权、网络与 SSH 环境诊断
118
+ compshare ask 产品使用和计费问答
119
+ compshare feedback 反馈 CLI 问题或建议
120
+ ```
121
+
122
+ ## 产品问答
123
+
124
+ ```bash
125
+ compshare ask "按量实例关机以后,云硬盘还收费吗?"
126
+ compshare --json ask "如何创建自定义镜像?"
127
+ ```
128
+
129
+ 普通输出显示答案和引用资料标题;`--json` 返回完整的答案、引用、请求 ID 和检索元数据。
130
+ 命令只向内置问答服务发送 `question` 字段,不会附带 API 凭证、配置文件或其他命令上下文。
131
+
132
+ ## 反馈
133
+
134
+ ```bash
135
+ compshare feedback bug "创建实例时发生错误"
136
+ compshare feedback suggest "希望支持保存默认创建规格"
137
+ ```
138
+
139
+ 反馈会直接发送到内置的 CompShare Insights 服务地址。开发环境可使用
140
+ `COMPSHARE_INSIGHTS_URL=http://127.0.0.1:18080` 覆盖服务地址。
141
+
142
+ CLI 会异步统计指令使用情况,且仅发送指令名称、CLI 版本、操作系统和发生时间;不会发送
143
+ 命令参数、凭证、资源 ID 或命令输出。
144
+
145
+ 查看完整命令和参数:
146
+
147
+ ```bash
148
+ compshare -h
149
+ compshare instance -h
150
+ compshare instance create -h
151
+ ```
152
+
153
+ ## 脚本调用
154
+
155
+ `--json`、`--profile` 和 `--show-sensitive` 是全局选项,必须放在子命令前:
156
+
157
+ ```bash
158
+ compshare --json instance list --status Running --all
159
+ compshare --profile production image list --source community --region cn-sh2 --zone cn-sh2-02
160
+ compshare --json --show-sensitive instance show uhost-xxxxxxxx
161
+ ```
162
+
163
+ JSON 模式不会启动交互向导。生命周期操作可使用 `--wait`、`--no-wait` 和
164
+ `--timeout` 控制等待行为;部分批量操作失败时,CLI 返回非零退出码。默认输出会递归隐藏
165
+ 密码、IP、访问 URL 和登录命令;只有显式指定 `--show-sensitive` 才会输出原值。
166
+
167
+ Region 和 Zone 是资源参数,放在对应子命令后:
168
+
169
+ ```bash
170
+ compshare instance list --region cn-sh2
171
+ compshare instance create --region cn-sh2 --zone cn-sh2-02
172
+ compshare image list --source custom --region cn-sh2 --zone cn-sh2-02
173
+ ```
174
+
175
+ CLI 不保存或自动注入默认 Region/Zone。非交互式地域资源操作需要显式传入;按实例 ID
176
+ 执行的生命周期操作使用 `DescribeCompShareInstance` 响应中的 Region 和 Zone;响应缺少任一
177
+ 字段时会停止操作,不会从 Zone 推导或用请求 Region 补齐。
178
+
179
+ ## 语言
180
+
181
+ ```bash
182
+ compshare lang en
183
+ compshare lang zh
184
+ compshare lang # 查看当前语言
185
+ ```
186
+
187
+ 也可以通过 `COMPSHARE_LANG=en` 临时覆盖。
188
+
189
+ ## 安全说明
190
+
191
+ - 配置目录和文件分别使用 `0700`、`0600` 权限。
192
+ - API 私钥不会出现在命令输出中。
193
+ - 默认使用 `***` 隐藏密码、私钥、IP、访问 URL、令牌和登录命令,包括嵌套 JSON 字段。
194
+ - `instance ssh` 在支持的交互式终端中通过伪终端自动填写登录密码,不会打印密码或将其放入进程参数。
195
+ - 自动登录会接受首次出现的 SSH 主机密钥;已记录主机的密钥发生变化时仍会拒绝连接。
196
+ - `instance ssh INSTANCE_ID -- COMMAND` 可非交互执行远程命令,透传命令输出和退出码。
197
+ - `instance scp INSTANCE_ID LOCAL_PATH REMOTE_PATH` 可自动认证并上传本地文件或目录。
198
+ - `--show-sensitive` 会恢复这些字段的原始值;请勿在共享终端、CI 日志或 Agent 会话中使用。
199
+ - 删除、关机、重启、重装和改配等操作默认要求确认。
200
+
201
+ ## 开发校验
202
+
203
+ ```bash
204
+ ruff check .
205
+ ruff format --check .
206
+ pytest
207
+ ```
208
+
209
+ 公开 API 覆盖范围和版本变化见 [CHANGELOG.md](CHANGELOG.md),维护者发布流程见
210
+ [RELEASING.md](RELEASING.md)。
@@ -1,25 +1,33 @@
1
1
  [build-system]
2
- requires = ["setuptools>=69"]
2
+ requires = ["setuptools>=77"]
3
3
  build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "compshare-cli"
7
- version = "0.1.3"
7
+ version = "0.3.0"
8
8
  description = "Command-line client for CompShare GPU compute"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
11
- license = { text = "Apache-2.0" }
11
+ license = "Apache-2.0"
12
+ license-files = ["LICENSE"]
12
13
  authors = [
13
14
  { name = "CompShare" },
14
15
  ]
15
16
  dependencies = [
16
17
  "click>=8.1,<9",
18
+ "pexpect>=4.9,<5; platform_system != 'Windows'",
17
19
  "rich>=13,<15",
18
20
  "typer>=0.12,<1",
19
21
  "ucloud-sdk-python3>=0.11.103,<0.12",
20
22
  "urllib3>=1.26.18,<2; python_version < '3.10' and platform_system == 'Darwin'",
21
23
  ]
22
24
 
25
+ [project.urls]
26
+ Homepage = "https://github.com/BennielAllan/compshare-cli"
27
+ Repository = "https://github.com/BennielAllan/compshare-cli"
28
+ Changelog = "https://github.com/BennielAllan/compshare-cli/blob/master/CHANGELOG.md"
29
+ Issues = "https://github.com/BennielAllan/compshare-cli/issues"
30
+
23
31
  [project.optional-dependencies]
24
32
  dev = [
25
33
  "pytest>=8,<10",
@@ -29,6 +37,7 @@ dev = [
29
37
 
30
38
  [project.scripts]
31
39
  compshare = "compshare_cli.cli:main"
40
+ compshare-ssh-askpass = "compshare_cli.ssh:askpass"
32
41
 
33
42
  [tool.setuptools.packages.find]
34
43
  where = ["src"]
@@ -1,3 +1,3 @@
1
1
  """CompShare command-line client."""
2
2
 
3
- __version__ = "0.1.3"
3
+ __version__ = "0.3.0"