runpod-shell 0.1.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.
- runpod_shell-0.1.0/LICENSE +176 -0
- runpod_shell-0.1.0/PKG-INFO +226 -0
- runpod_shell-0.1.0/README.md +213 -0
- runpod_shell-0.1.0/pyproject.toml +25 -0
- runpod_shell-0.1.0/setup.cfg +4 -0
- runpod_shell-0.1.0/src/runpod_shell/__init__.py +1 -0
- runpod_shell-0.1.0/src/runpod_shell/__main__.py +5 -0
- runpod_shell-0.1.0/src/runpod_shell/cli.py +838 -0
- runpod_shell-0.1.0/src/runpod_shell/ssh_runner.py +382 -0
- runpod_shell-0.1.0/src/runpod_shell.egg-info/PKG-INFO +226 -0
- runpod_shell-0.1.0/src/runpod_shell.egg-info/SOURCES.txt +15 -0
- runpod_shell-0.1.0/src/runpod_shell.egg-info/dependency_links.txt +1 -0
- runpod_shell-0.1.0/src/runpod_shell.egg-info/entry_points.txt +2 -0
- runpod_shell-0.1.0/src/runpod_shell.egg-info/requires.txt +1 -0
- runpod_shell-0.1.0/src/runpod_shell.egg-info/top_level.txt +1 -0
- runpod_shell-0.1.0/test/test_cli.py +388 -0
- runpod_shell-0.1.0/test/test_ssh_runner.py +173 -0
|
@@ -0,0 +1,176 @@
|
|
|
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 Work text from the Licensor, 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
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: runpod-shell
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A Python command-line interface to manage RunPod instances
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: Operating System :: OS Independent
|
|
8
|
+
Requires-Python: >=3.8
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Dist: runpod
|
|
12
|
+
Dynamic: license-file
|
|
13
|
+
|
|
14
|
+
# RunPod Shell CLI
|
|
15
|
+
|
|
16
|
+
A Python command-line interface to manage RunPod instances (create, list, stop, and terminate pods) with optional persistent network volumes, customized container environments, and automatic SSH setup.
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
- **Docker-like Subcommands**: Simple interface to `create`, `list`, `stop`, `terminate`, and list `gpus`.
|
|
21
|
+
- **GPU Querying & Resolution**: List all available GPU types using the `gpus` subcommand, and use case-insensitive, unique substring, or fuzzy matching auto-resolution for `--gpu-type` values (e.g. `4090` auto-resolves to `NVIDIA GeForce RTX 4090`).
|
|
22
|
+
- **Smart SSH Key Auto-Detection**: Searches for standard SSH public keys (`id_rsa.pub`, `id_ed25519.pub`, `id_ecdsa.pub`, `id_dsa.pub`) in your local `~/.ssh/` directory automatically.
|
|
23
|
+
- **Python Virtual Environments**: Resolves packages from `requirements.txt` (or custom path) and `--pip-packages` (CLI) and installs them in a persistent virtual environment (`/workspace/venv`).
|
|
24
|
+
- **Container Customization**: Merges CLI and file-based apt packages (via `--apt-packages` and `--apt-packages-file`) and loads credentials from a `.env` file (via `--env-file`).
|
|
25
|
+
- **Real SSH Address Output**: Resolves the exact host IP and external port from RunPod to print a ready-to-use SSH connection string.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
1. **Install the package**:
|
|
32
|
+
```bash
|
|
33
|
+
pip install .
|
|
34
|
+
```
|
|
35
|
+
Or for editable development mode:
|
|
36
|
+
```bash
|
|
37
|
+
pip install -e .
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
2. **RunPod API Key**:
|
|
41
|
+
Obtain an API key from your RunPod settings and expose it:
|
|
42
|
+
```bash
|
|
43
|
+
export RUNPOD_API_KEY="your_runpod_api_key"
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
> **Note:** Once installed, the `runpod-shell` executable is available in your `PATH`. Alternatively, you can run commands via the Python module syntax: `python3 -m runpod_shell <subcommand>`.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Command Reference
|
|
51
|
+
|
|
52
|
+
### Global Option
|
|
53
|
+
Every subcommand supports passing the API key directly:
|
|
54
|
+
* `--api-key`: RunPod API key (or uses the local `RUNPOD_API_KEY` env var).
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
### 1. `create`
|
|
59
|
+
Launches and configures a new RunPod instance.
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
runpod-shell create [OPTIONS]
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
| Flag | Default | Description |
|
|
66
|
+
|---|---|---|
|
|
67
|
+
| `--name` | `persistent-worker` | Name of the RunPod instance |
|
|
68
|
+
| `--volume-id` | *None* | Persistent Network Volume ID to mount |
|
|
69
|
+
| `--image-name` | `runpod/pytorch:1.0.2-cu1281-torch280-ubuntu2404` | Base image for the container |
|
|
70
|
+
| `--gpu-type` | `NVIDIA GeForce RTX 4090` | GPU type ID to provision (supports case-insensitive, unique substring, and fuzzy matching, e.g. `4090`) |
|
|
71
|
+
| `--gpu-count` | `1` | Number of GPUs to allocate |
|
|
72
|
+
| `--volume-size` | `50` | Container disk size in GB |
|
|
73
|
+
| `--ssh-key-path` | *None* | Path to public key (checks default paths if omitted) |
|
|
74
|
+
| `--requirements-path` | *None* | Path to `requirements.txt` file |
|
|
75
|
+
| `--pip-packages` | *None* | Extra Python packages to install |
|
|
76
|
+
| `--apt-packages` | *None* | Extra apt packages to install (default: `screen curl htop ffmpeg git`) |
|
|
77
|
+
| `--apt-packages-file` | *None* | Path to a file containing extra apt packages to install |
|
|
78
|
+
| `--env` | *None* | Environment variables (e.g. `KEY=VALUE`) |
|
|
79
|
+
| `--env-file` | *None* | Path to a `.env` file containing environment variables |
|
|
80
|
+
| `--ports` | `22/tcp` | Container ports to expose |
|
|
81
|
+
| `--cloud-type` | `SECURE` | Type of cloud network (`SECURE`, `COMMUNITY`, or `ALL`) |
|
|
82
|
+
| `--container-disk-size` | `30` | Container local disk size in GB |
|
|
83
|
+
| `--volume-mount-path` | `/workspace` | Path inside container where the network volume is mounted |
|
|
84
|
+
| `--vcpu-count` | `4` | Minimum number of vCPUs to allocate |
|
|
85
|
+
| `--memory` | `8` | Minimum CPU RAM in GB to allocate |
|
|
86
|
+
| `--run-script` | *None* | Path to a local script to execute on the pod via SSH once initialized |
|
|
87
|
+
| `--script-args` | `""` | String arguments to pass to the script |
|
|
88
|
+
| `-d`, `--detach` | `False` | Run script in background without waiting / streaming |
|
|
89
|
+
| `--ssh-private-key-path` | *None* | Path to private SSH key (auto-detected if omitted) |
|
|
90
|
+
| `--no-wait-for-setup` | `False` | Do not wait for container disk setup to complete before executing script |
|
|
91
|
+
| `--ssh-timeout` | `180` | Max seconds to wait for SSH and setup readiness |
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
### 2. `list`
|
|
96
|
+
Lists all active and stopped pods associated with your account, showing Pod ID, Name, Status, GPU type, and connection endpoint.
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
runpod-shell list
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
### 3. `stop`
|
|
105
|
+
Stops a running pod (releases GPU resources, but retains the data on the persistent network volume).
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
runpod-shell stop <pod-id>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
### 4. `terminate`
|
|
114
|
+
Deletes a pod and releases all associated resources.
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
runpod-shell terminate <pod-id>
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
### 5. `gpus`
|
|
123
|
+
Retrieves and lists all available GPU models, including display names, VRAM sizes, CUDA Cores, maximum GPU configurations, and hourly pricing (Secure vs. Community cloud).
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
runpod-shell gpus
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
### 6. `exec`
|
|
132
|
+
Uploads and executes an arbitrary local script on an active pod via SSH. Supports foreground streaming or detached background execution.
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
runpod-shell exec <pod-id> <script-path> [OPTIONS]
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
| Flag | Default | Description |
|
|
139
|
+
|---|---|---|
|
|
140
|
+
| `--script-args` | `""` | String arguments to pass to the script |
|
|
141
|
+
| `-d`, `--detach` | `False` | Run script in background without waiting / streaming |
|
|
142
|
+
| `--ssh-private-key-path` | *None* | Path to private SSH key (auto-detected if omitted) |
|
|
143
|
+
| `--no-wait-for-setup` | `False` | Do not wait for container disk setup to complete |
|
|
144
|
+
| `--ssh-timeout` | `180` | Max seconds to wait for SSH and setup readiness |
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
### 7. `ps`
|
|
149
|
+
Lists remote processes and background jobs managed by `runpod-shell` on the pod, including Job ID, PID, running/completed/failed status, start time, duration, and log file path.
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
runpod-shell ps <pod-id>
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
### 8. `logs`
|
|
158
|
+
Inspects remote execution logs with full display (`cat`), tailing the last N lines, or live streaming (`-f`).
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
# Display entire log (cat)
|
|
162
|
+
runpod-shell logs <pod-id> [job-id]
|
|
163
|
+
|
|
164
|
+
# Show last 100 lines
|
|
165
|
+
runpod-shell logs <pod-id> [job-id] -n 100
|
|
166
|
+
|
|
167
|
+
# Live follow log output (tail -f)
|
|
168
|
+
runpod-shell logs <pod-id> [job-id] -f
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
### 9. `kill`
|
|
174
|
+
Terminates a remote job and its entire process group using a signal (defaults to `SIGTERM`).
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
runpod-shell kill <pod-id> <job-id-or-pid> [--signal SIGKILL]
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## Examples
|
|
183
|
+
|
|
184
|
+
### Launch with default settings
|
|
185
|
+
```bash
|
|
186
|
+
runpod-shell create
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Launch attaching a Network Volume and Python requirements
|
|
190
|
+
```bash
|
|
191
|
+
runpod-shell create --volume-id "vol-abc123xyz" --requirements-path requirements.txt
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Launch and automatically run a script in the background
|
|
195
|
+
```bash
|
|
196
|
+
runpod-shell create \
|
|
197
|
+
--volume-id "vol-abc123xyz" \
|
|
198
|
+
--run-script ./train.py \
|
|
199
|
+
--script-args "--epochs 50 --lr 1e-4" \
|
|
200
|
+
--detach
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Execute a script on an existing pod and follow logs
|
|
204
|
+
```bash
|
|
205
|
+
# Run in background
|
|
206
|
+
runpod-shell exec pod-abc123xyz ./eval.py --script-args "--model best.pt" -d
|
|
207
|
+
|
|
208
|
+
# Check process status
|
|
209
|
+
runpod-shell ps pod-abc123xyz
|
|
210
|
+
|
|
211
|
+
# Follow live output
|
|
212
|
+
runpod-shell logs pod-abc123xyz -f
|
|
213
|
+
|
|
214
|
+
# Terminate if needed
|
|
215
|
+
runpod-shell kill pod-abc123xyz job-1757000000-a1b2c3
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Fully customized creation
|
|
219
|
+
```bash
|
|
220
|
+
runpod-shell create \
|
|
221
|
+
--image-name "runpod/pytorch:2.4.0-py3.11-cuda12.4.1-ubuntu22.04" \
|
|
222
|
+
--gpu-type "NVIDIA RTX A6000" \
|
|
223
|
+
--gpu-count 2 \
|
|
224
|
+
--env-file secrets.env \
|
|
225
|
+
--pip-packages torchinfo matplotlib
|
|
226
|
+
```
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
# RunPod Shell CLI
|
|
2
|
+
|
|
3
|
+
A Python command-line interface to manage RunPod instances (create, list, stop, and terminate pods) with optional persistent network volumes, customized container environments, and automatic SSH setup.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Docker-like Subcommands**: Simple interface to `create`, `list`, `stop`, `terminate`, and list `gpus`.
|
|
8
|
+
- **GPU Querying & Resolution**: List all available GPU types using the `gpus` subcommand, and use case-insensitive, unique substring, or fuzzy matching auto-resolution for `--gpu-type` values (e.g. `4090` auto-resolves to `NVIDIA GeForce RTX 4090`).
|
|
9
|
+
- **Smart SSH Key Auto-Detection**: Searches for standard SSH public keys (`id_rsa.pub`, `id_ed25519.pub`, `id_ecdsa.pub`, `id_dsa.pub`) in your local `~/.ssh/` directory automatically.
|
|
10
|
+
- **Python Virtual Environments**: Resolves packages from `requirements.txt` (or custom path) and `--pip-packages` (CLI) and installs them in a persistent virtual environment (`/workspace/venv`).
|
|
11
|
+
- **Container Customization**: Merges CLI and file-based apt packages (via `--apt-packages` and `--apt-packages-file`) and loads credentials from a `.env` file (via `--env-file`).
|
|
12
|
+
- **Real SSH Address Output**: Resolves the exact host IP and external port from RunPod to print a ready-to-use SSH connection string.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
1. **Install the package**:
|
|
19
|
+
```bash
|
|
20
|
+
pip install .
|
|
21
|
+
```
|
|
22
|
+
Or for editable development mode:
|
|
23
|
+
```bash
|
|
24
|
+
pip install -e .
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
2. **RunPod API Key**:
|
|
28
|
+
Obtain an API key from your RunPod settings and expose it:
|
|
29
|
+
```bash
|
|
30
|
+
export RUNPOD_API_KEY="your_runpod_api_key"
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
> **Note:** Once installed, the `runpod-shell` executable is available in your `PATH`. Alternatively, you can run commands via the Python module syntax: `python3 -m runpod_shell <subcommand>`.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Command Reference
|
|
38
|
+
|
|
39
|
+
### Global Option
|
|
40
|
+
Every subcommand supports passing the API key directly:
|
|
41
|
+
* `--api-key`: RunPod API key (or uses the local `RUNPOD_API_KEY` env var).
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
### 1. `create`
|
|
46
|
+
Launches and configures a new RunPod instance.
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
runpod-shell create [OPTIONS]
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
| Flag | Default | Description |
|
|
53
|
+
|---|---|---|
|
|
54
|
+
| `--name` | `persistent-worker` | Name of the RunPod instance |
|
|
55
|
+
| `--volume-id` | *None* | Persistent Network Volume ID to mount |
|
|
56
|
+
| `--image-name` | `runpod/pytorch:1.0.2-cu1281-torch280-ubuntu2404` | Base image for the container |
|
|
57
|
+
| `--gpu-type` | `NVIDIA GeForce RTX 4090` | GPU type ID to provision (supports case-insensitive, unique substring, and fuzzy matching, e.g. `4090`) |
|
|
58
|
+
| `--gpu-count` | `1` | Number of GPUs to allocate |
|
|
59
|
+
| `--volume-size` | `50` | Container disk size in GB |
|
|
60
|
+
| `--ssh-key-path` | *None* | Path to public key (checks default paths if omitted) |
|
|
61
|
+
| `--requirements-path` | *None* | Path to `requirements.txt` file |
|
|
62
|
+
| `--pip-packages` | *None* | Extra Python packages to install |
|
|
63
|
+
| `--apt-packages` | *None* | Extra apt packages to install (default: `screen curl htop ffmpeg git`) |
|
|
64
|
+
| `--apt-packages-file` | *None* | Path to a file containing extra apt packages to install |
|
|
65
|
+
| `--env` | *None* | Environment variables (e.g. `KEY=VALUE`) |
|
|
66
|
+
| `--env-file` | *None* | Path to a `.env` file containing environment variables |
|
|
67
|
+
| `--ports` | `22/tcp` | Container ports to expose |
|
|
68
|
+
| `--cloud-type` | `SECURE` | Type of cloud network (`SECURE`, `COMMUNITY`, or `ALL`) |
|
|
69
|
+
| `--container-disk-size` | `30` | Container local disk size in GB |
|
|
70
|
+
| `--volume-mount-path` | `/workspace` | Path inside container where the network volume is mounted |
|
|
71
|
+
| `--vcpu-count` | `4` | Minimum number of vCPUs to allocate |
|
|
72
|
+
| `--memory` | `8` | Minimum CPU RAM in GB to allocate |
|
|
73
|
+
| `--run-script` | *None* | Path to a local script to execute on the pod via SSH once initialized |
|
|
74
|
+
| `--script-args` | `""` | String arguments to pass to the script |
|
|
75
|
+
| `-d`, `--detach` | `False` | Run script in background without waiting / streaming |
|
|
76
|
+
| `--ssh-private-key-path` | *None* | Path to private SSH key (auto-detected if omitted) |
|
|
77
|
+
| `--no-wait-for-setup` | `False` | Do not wait for container disk setup to complete before executing script |
|
|
78
|
+
| `--ssh-timeout` | `180` | Max seconds to wait for SSH and setup readiness |
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
### 2. `list`
|
|
83
|
+
Lists all active and stopped pods associated with your account, showing Pod ID, Name, Status, GPU type, and connection endpoint.
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
runpod-shell list
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
### 3. `stop`
|
|
92
|
+
Stops a running pod (releases GPU resources, but retains the data on the persistent network volume).
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
runpod-shell stop <pod-id>
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
### 4. `terminate`
|
|
101
|
+
Deletes a pod and releases all associated resources.
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
runpod-shell terminate <pod-id>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
### 5. `gpus`
|
|
110
|
+
Retrieves and lists all available GPU models, including display names, VRAM sizes, CUDA Cores, maximum GPU configurations, and hourly pricing (Secure vs. Community cloud).
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
runpod-shell gpus
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
### 6. `exec`
|
|
119
|
+
Uploads and executes an arbitrary local script on an active pod via SSH. Supports foreground streaming or detached background execution.
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
runpod-shell exec <pod-id> <script-path> [OPTIONS]
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
| Flag | Default | Description |
|
|
126
|
+
|---|---|---|
|
|
127
|
+
| `--script-args` | `""` | String arguments to pass to the script |
|
|
128
|
+
| `-d`, `--detach` | `False` | Run script in background without waiting / streaming |
|
|
129
|
+
| `--ssh-private-key-path` | *None* | Path to private SSH key (auto-detected if omitted) |
|
|
130
|
+
| `--no-wait-for-setup` | `False` | Do not wait for container disk setup to complete |
|
|
131
|
+
| `--ssh-timeout` | `180` | Max seconds to wait for SSH and setup readiness |
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
### 7. `ps`
|
|
136
|
+
Lists remote processes and background jobs managed by `runpod-shell` on the pod, including Job ID, PID, running/completed/failed status, start time, duration, and log file path.
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
runpod-shell ps <pod-id>
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
### 8. `logs`
|
|
145
|
+
Inspects remote execution logs with full display (`cat`), tailing the last N lines, or live streaming (`-f`).
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
# Display entire log (cat)
|
|
149
|
+
runpod-shell logs <pod-id> [job-id]
|
|
150
|
+
|
|
151
|
+
# Show last 100 lines
|
|
152
|
+
runpod-shell logs <pod-id> [job-id] -n 100
|
|
153
|
+
|
|
154
|
+
# Live follow log output (tail -f)
|
|
155
|
+
runpod-shell logs <pod-id> [job-id] -f
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
### 9. `kill`
|
|
161
|
+
Terminates a remote job and its entire process group using a signal (defaults to `SIGTERM`).
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
runpod-shell kill <pod-id> <job-id-or-pid> [--signal SIGKILL]
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Examples
|
|
170
|
+
|
|
171
|
+
### Launch with default settings
|
|
172
|
+
```bash
|
|
173
|
+
runpod-shell create
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Launch attaching a Network Volume and Python requirements
|
|
177
|
+
```bash
|
|
178
|
+
runpod-shell create --volume-id "vol-abc123xyz" --requirements-path requirements.txt
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Launch and automatically run a script in the background
|
|
182
|
+
```bash
|
|
183
|
+
runpod-shell create \
|
|
184
|
+
--volume-id "vol-abc123xyz" \
|
|
185
|
+
--run-script ./train.py \
|
|
186
|
+
--script-args "--epochs 50 --lr 1e-4" \
|
|
187
|
+
--detach
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Execute a script on an existing pod and follow logs
|
|
191
|
+
```bash
|
|
192
|
+
# Run in background
|
|
193
|
+
runpod-shell exec pod-abc123xyz ./eval.py --script-args "--model best.pt" -d
|
|
194
|
+
|
|
195
|
+
# Check process status
|
|
196
|
+
runpod-shell ps pod-abc123xyz
|
|
197
|
+
|
|
198
|
+
# Follow live output
|
|
199
|
+
runpod-shell logs pod-abc123xyz -f
|
|
200
|
+
|
|
201
|
+
# Terminate if needed
|
|
202
|
+
runpod-shell kill pod-abc123xyz job-1757000000-a1b2c3
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Fully customized creation
|
|
206
|
+
```bash
|
|
207
|
+
runpod-shell create \
|
|
208
|
+
--image-name "runpod/pytorch:2.4.0-py3.11-cuda12.4.1-ubuntu22.04" \
|
|
209
|
+
--gpu-type "NVIDIA RTX A6000" \
|
|
210
|
+
--gpu-count 2 \
|
|
211
|
+
--env-file secrets.env \
|
|
212
|
+
--pip-packages torchinfo matplotlib
|
|
213
|
+
```
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "runpod-shell"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "A Python command-line interface to manage RunPod instances"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "Apache-2.0"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
requires-python = ">=3.8"
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Programming Language :: Python :: 3",
|
|
15
|
+
"Operating System :: OS Independent",
|
|
16
|
+
]
|
|
17
|
+
dependencies = [
|
|
18
|
+
"runpod",
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
[project.scripts]
|
|
22
|
+
runpod-shell = "runpod_shell.cli:main"
|
|
23
|
+
|
|
24
|
+
[tool.setuptools.packages.find]
|
|
25
|
+
where = ["src"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Package runpod_shell
|