colabapi 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.
- colabapi-0.1.0/LICENSE +21 -0
- colabapi-0.1.0/PKG-INFO +232 -0
- colabapi-0.1.0/README.md +201 -0
- colabapi-0.1.0/colabapi/__init__.py +7 -0
- colabapi-0.1.0/colabapi/cli.py +446 -0
- colabapi-0.1.0/colabapi/colabcli.py +219 -0
- colabapi-0.1.0/colabapi/config.py +148 -0
- colabapi-0.1.0/colabapi/keepalive.py +64 -0
- colabapi-0.1.0/colabapi/monitor.py +145 -0
- colabapi-0.1.0/colabapi/runtime.py +85 -0
- colabapi-0.1.0/colabapi/service.py +73 -0
- colabapi-0.1.0/colabapi/shellview.py +108 -0
- colabapi-0.1.0/colabapi/timing.py +53 -0
- colabapi-0.1.0/colabapi/ui.py +102 -0
- colabapi-0.1.0/colabapi.egg-info/PKG-INFO +232 -0
- colabapi-0.1.0/colabapi.egg-info/SOURCES.txt +20 -0
- colabapi-0.1.0/colabapi.egg-info/dependency_links.txt +1 -0
- colabapi-0.1.0/colabapi.egg-info/entry_points.txt +2 -0
- colabapi-0.1.0/colabapi.egg-info/requires.txt +3 -0
- colabapi-0.1.0/colabapi.egg-info/top_level.txt +1 -0
- colabapi-0.1.0/pyproject.toml +63 -0
- colabapi-0.1.0/setup.cfg +4 -0
colabapi-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 lil-limbo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
colabapi-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: colabapi
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Run and keep a Google Colab runtime alive, then reach its terminal from your own server or laptop. A CLI for headless, persistent Colab sessions.
|
|
5
|
+
Author: lil-limbo
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/lil-limbo/colabapi
|
|
8
|
+
Project-URL: Repository, https://github.com/lil-limbo/colabapi
|
|
9
|
+
Project-URL: Issues, https://github.com/lil-limbo/colabapi/issues
|
|
10
|
+
Keywords: google colab,colab,colab terminal,colab ssh,colab cli,persistent colab,colab keep alive,headless colab,colab runtime,jupyter,gpu,remote terminal,vps
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
16
|
+
Classifier: Operating System :: MacOS
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Topic :: System :: Distributed Computing
|
|
23
|
+
Classifier: Topic :: Utilities
|
|
24
|
+
Requires-Python: >=3.9
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Requires-Dist: click>=8.1
|
|
28
|
+
Requires-Dist: rich>=13.0
|
|
29
|
+
Requires-Dist: google-colab-cli>=0.6.0
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
# colabapi: a terminal for a persistent Google Colab runtime
|
|
33
|
+
|
|
34
|
+
**Run Google Colab from your own terminal, keep the runtime alive after you close the browser, and reach its shell from any VPS or laptop.** `colabapi` is a small, open source command line tool that turns a Google Colab GPU/TPU session into something you can drive headlessly. Perfect for demos, MVPs, and long running jobs that must survive after the Colab web tab is gone.
|
|
35
|
+
|
|
36
|
+
> **In one line:** `colabapi` gives you a persistent Colab terminal on your own server, using Google's official, ban safe sign in and tunnel, and it never sees your Google password.
|
|
37
|
+
|
|
38
|
+
<!-- Keywords: google colab terminal, colab cli, colab ssh, persistent colab, keep colab alive, headless colab, run colab from terminal, colab gpu terminal, colab from vps, colab session keep alive -->
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Why colabapi?
|
|
43
|
+
|
|
44
|
+
Google Colab is fantastic free (and paid) GPU/TPU compute, but it only lives inside a browser tab. Close the tab or lose your connection and the session can go with it. That makes it awkward to:
|
|
45
|
+
|
|
46
|
+
- **demo an MVP** that needs a GPU without renting a server,
|
|
47
|
+
- **reach the runtime from a VPS** or a headless box,
|
|
48
|
+
- **register it as a background service** that stays up, or
|
|
49
|
+
- **watch CPU / GPU / RAM** from a normal terminal.
|
|
50
|
+
|
|
51
|
+
`colabapi` solves this by wrapping **Google's official [`google-colab-cli`](https://github.com/googlecolab/google-colab-cli)** with a friendly single command, a systemd service, a runtime picker, a live resource monitor, and a session time display. You sign in through Google's own browser flow; `colabapi` connects over Google's sanctioned tunnel.
|
|
52
|
+
|
|
53
|
+
## Features
|
|
54
|
+
|
|
55
|
+
- 🔐 **Browser sign in, no password handling.** Authentication happens in Google's own login flow (including 2FA / device checks). `colabapi` never asks for, stores, or transmits your Google credentials.
|
|
56
|
+
- 💻 **Real terminal into the runtime.** `colabapi shell` drops you into a live PTY on the Colab VM. `colabapi repl` gives you a Python REPL.
|
|
57
|
+
- 🎛 **Runtime picker.** List CPU / T4 / L4 / G4 / A100 / H100 / TPU options; paid tier runtimes are clearly flagged as unavailable on a free account.
|
|
58
|
+
- 📈 **Live CPU / GPU / RAM monitor.** `colabapi monitor` streams runtime stats to your terminal (psutil + `nvidia-smi`).
|
|
59
|
+
- ⏱ **Session time display.** See uptime and an estimate of how long before Colab's max lifetime cap.
|
|
60
|
+
- ♻️ **Keepalive that resists the idle timeout.** Google's official daemon does the primary keepalive; `colabapi` adds a supervisory health check.
|
|
61
|
+
- 🧩 **Runs as a Linux service.** `colabapi service install` registers a systemd user service so your session survives logout.
|
|
62
|
+
- 🔎 **Inspectable & MIT licensed.** Read every line. Nothing phones home.
|
|
63
|
+
|
|
64
|
+
## How it works
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
you > colabapi (this tool) > colab (Google's official CLI) > Google's tunnel > your Colab runtime (GPU/TPU VM)
|
|
68
|
+
|
|
69
|
+
colabapi adds: runtime picker, monitor, session timer, systemd service
|
|
70
|
+
colabapi never handles your Google password
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
`colabapi` is an **orchestration and UX layer**. The heavy lifting (OAuth sign in, allocating the runtime, and the encrypted terminal tunnel) is delegated to Google's first party CLI, which is the safe, supported way to do this.
|
|
74
|
+
|
|
75
|
+
## Install
|
|
76
|
+
|
|
77
|
+
**One command installs the whole system.** Google's official Colab CLI is pulled in automatically as a dependency, so you never install it separately.
|
|
78
|
+
|
|
79
|
+
### With pipx (recommended)
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
pipx install colabapi
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### With pip
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
pip install --user colabapi
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
> **On Kali / Debian / Ubuntu** you may hit `error: externally-managed-environment` (PEP 668). This is the OS protecting its system Python, not a colabapi problem. Use `pipx` (above), a virtualenv, or override it:
|
|
92
|
+
>
|
|
93
|
+
> ```bash
|
|
94
|
+
> pip install --user colabapi --break-system-packages
|
|
95
|
+
> ```
|
|
96
|
+
|
|
97
|
+
### One line install script
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
curl -fsSL https://raw.githubusercontent.com/lil-limbo/colabapi/main/scripts/install.sh | bash
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### From source
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
git clone https://github.com/lil-limbo/colabapi.git
|
|
107
|
+
cd colabapi
|
|
108
|
+
pip install -e .
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
> **On Kali / Debian / Ubuntu**, `pip install -e .` may fail with `externally-managed-environment` (PEP 668). Pick one:
|
|
112
|
+
>
|
|
113
|
+
> ```bash
|
|
114
|
+
> # Option A: override the guard (quickest)
|
|
115
|
+
> pip install -e . --break-system-packages
|
|
116
|
+
>
|
|
117
|
+
> # Option B: use an isolated virtualenv (cleanest)
|
|
118
|
+
> python3 -m venv .venv && source .venv/bin/activate && pip install -e .
|
|
119
|
+
> ```
|
|
120
|
+
|
|
121
|
+
**Requirement:** Python 3.9+. That's it. Everything else installs with the package.
|
|
122
|
+
|
|
123
|
+
Verify everything is wired up:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
colabapi doctor
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Quickstart
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# 1. Sign in (opens Google's own login in your browser, no password asked)
|
|
133
|
+
colabapi login
|
|
134
|
+
|
|
135
|
+
# 2. Pick a runtime, then name the session when asked
|
|
136
|
+
colabapi run # interactive picker + name prompt
|
|
137
|
+
colabapi run --runtime t4 # or go straight to a T4 GPU
|
|
138
|
+
|
|
139
|
+
# 3. Use it (omit the name to pick from an arrow-key list)
|
|
140
|
+
colabapi shell # terminal on the session, live monitor on top
|
|
141
|
+
colabapi monitor # live CPU / GPU / RAM
|
|
142
|
+
colabapi sessions # list your sessions
|
|
143
|
+
colabapi status # reachability + estimated time remaining
|
|
144
|
+
colabapi stop # stop a session (or: colabapi stop <name>)
|
|
145
|
+
|
|
146
|
+
# 4. Keep it alive after you log out of your server
|
|
147
|
+
colabapi service install
|
|
148
|
+
systemctl --user start colabapi
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Press **Ctrl+C** to leave the monitor; type **`exit`** or press **Ctrl+D** to leave the shell. The Colab runtime keeps running until you stop it or Colab's timers end it.
|
|
152
|
+
|
|
153
|
+
## Command reference
|
|
154
|
+
|
|
155
|
+
| Command | What it does |
|
|
156
|
+
|---|---|
|
|
157
|
+
| `colabapi login` | Sign in via Google's browser flow (no password handled). |
|
|
158
|
+
| `colabapi runtimes` | List runtime types and which need a paid plan. |
|
|
159
|
+
| `colabapi run [--runtime KEY]` | Allocate a runtime and name the session (delegates to `colab new -s NAME`). |
|
|
160
|
+
| `colabapi sessions` | List the sessions colabapi manages. |
|
|
161
|
+
| `colabapi shell [NAME]` | Terminal on a session with a live monitor on top; arrow-key picker if NAME omitted. |
|
|
162
|
+
| `colabapi repl [NAME]` | Interactive Python REPL on a session (`colab repl`). |
|
|
163
|
+
| `colabapi monitor [NAME]` | Live CPU / GPU / RAM monitor for a session. |
|
|
164
|
+
| `colabapi status [NAME]` | Session reachability and estimated time left. |
|
|
165
|
+
| `colabapi stop [NAME]` | Stop a session (`colab stop`); arrow-key picker if NAME omitted. |
|
|
166
|
+
| `colabapi daemon [NAME]` | Supervisory keepalive (used by the service). |
|
|
167
|
+
| `colabapi service install\|uninstall\|status` | Manage the systemd user service. |
|
|
168
|
+
| `colabapi doctor` | Check your environment and the `colab` CLI interface. |
|
|
169
|
+
| `colabapi raw -- <args>` | Passthrough to the official `colab` CLI. |
|
|
170
|
+
|
|
171
|
+
## Running as a Linux service
|
|
172
|
+
|
|
173
|
+
`colabapi` installs as a **systemd user service** (no root required):
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
colabapi service install # writes ~/.config/systemd/user/colabapi.service and enables lingering
|
|
177
|
+
systemctl --user start colabapi
|
|
178
|
+
systemctl --user status colabapi
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Lingering (`loginctl enable-linger`) lets the service keep running after you disconnect from the VPS, which is exactly what you want for an always on demo.
|
|
182
|
+
|
|
183
|
+
## Privacy
|
|
184
|
+
|
|
185
|
+
**We do not capture your login data. We do not collect anything.**
|
|
186
|
+
|
|
187
|
+
- `colabapi` has **no code path that asks for, reads, stores, or transmits your Google password.** Sign in is delegated entirely to Google's official CLI and happens in your own browser under Google's real login flow.
|
|
188
|
+
- `colabapi` operates **no servers**. There is nothing for your data to be sent to. The only network connections are between *your* machine, Google, and (via the official CLI) *your* Colab runtime.
|
|
189
|
+
- The only things written to disk are **plain preferences and session bookkeeping** (which runtime you picked and when), under `~/.config/colabapi` and `~/.local/state/colabapi`.
|
|
190
|
+
- The project is **MIT licensed and fully open source.** [Read the code](https://github.com/lil-limbo/colabapi/tree/main/colabapi). If you don't trust a claim here, verify it in the source. That's the point.
|
|
191
|
+
|
|
192
|
+
## Safety & Colab's limits (please read)
|
|
193
|
+
|
|
194
|
+
`colabapi` deliberately uses **Google's official CLI** instead of the older "SSH into Colab via ngrok/cloudflared" trick, because Colab's own FAQ lists *remote control such as SSH shells* as an activity that can get a runtime (or an account) terminated. Using the sanctioned path is far safer for your Google account.
|
|
195
|
+
|
|
196
|
+
Two limits **nobody** can bypass, and `colabapi` doesn't pretend to:
|
|
197
|
+
|
|
198
|
+
- **Idle timeout (~90 min):** avoided by the keepalive while a session is active.
|
|
199
|
+
- **Absolute max lifetime (~12 h free, up to 24 h paid):** a hard cap. `colabapi` shows an *estimate* of time left, but Google enforces the ceiling.
|
|
200
|
+
|
|
201
|
+
Be a good citizen: don't hold GPU runtimes idle just to reserve them. Aggressive keepalive can get an account flagged.
|
|
202
|
+
|
|
203
|
+
## FAQ
|
|
204
|
+
|
|
205
|
+
**Does colabapi see or store my Google password?**
|
|
206
|
+
No. Sign in is handled by Google's official CLI in your browser. `colabapi` has no password code path at all.
|
|
207
|
+
|
|
208
|
+
**How do I keep a Google Colab session alive after closing the browser?**
|
|
209
|
+
Allocate a runtime with `colabapi run`, then install the service (`colabapi service install`). Google's keepalive holds off the idle timeout; the systemd service keeps `colabapi` supervising it after you log out.
|
|
210
|
+
|
|
211
|
+
**Can I get a terminal / shell into Google Colab?**
|
|
212
|
+
Yes. `colabapi shell` opens a live PTY on the runtime via Google's `colab console`. `colabapi repl` gives a Python REPL.
|
|
213
|
+
|
|
214
|
+
**Can I use a free Colab account?**
|
|
215
|
+
Yes. CPU and T4 GPU runtimes are available on the free tier. Paid runtimes (L4, A100, H100, TPU) are shown but flagged; Colab itself refuses them on free accounts.
|
|
216
|
+
|
|
217
|
+
**How is this different from Google's official `colab` CLI?**
|
|
218
|
+
`colabapi` *uses* the official CLI under the hood and adds a single `colabapi` command, a runtime picker with paid tier flags, a live resource monitor, a session timer, and a ready made systemd service. If you only need raw commands, use `colab` directly; if you want the persistent service demo workflow, use `colabapi`.
|
|
219
|
+
|
|
220
|
+
**Does it work on a VPS / headless server?**
|
|
221
|
+
Yes, that's the main use case. Sign in once in a browser, then run everything from the server, optionally as a systemd service.
|
|
222
|
+
|
|
223
|
+
**Is this affiliated with Google?**
|
|
224
|
+
No. `colabapi` is an independent, open source wrapper. "Google Colab" is a trademark of Google LLC.
|
|
225
|
+
|
|
226
|
+
## Contributing
|
|
227
|
+
|
|
228
|
+
Issues and pull requests welcome. If Google changes the official CLI's flags, the runtime→flag mapping lives in a single file (`colabapi/runtime.py`) and `colabapi doctor` will flag drift.
|
|
229
|
+
|
|
230
|
+
## License
|
|
231
|
+
|
|
232
|
+
MIT. See [LICENSE](LICENSE).
|
colabapi-0.1.0/README.md
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
# colabapi: a terminal for a persistent Google Colab runtime
|
|
2
|
+
|
|
3
|
+
**Run Google Colab from your own terminal, keep the runtime alive after you close the browser, and reach its shell from any VPS or laptop.** `colabapi` is a small, open source command line tool that turns a Google Colab GPU/TPU session into something you can drive headlessly. Perfect for demos, MVPs, and long running jobs that must survive after the Colab web tab is gone.
|
|
4
|
+
|
|
5
|
+
> **In one line:** `colabapi` gives you a persistent Colab terminal on your own server, using Google's official, ban safe sign in and tunnel, and it never sees your Google password.
|
|
6
|
+
|
|
7
|
+
<!-- Keywords: google colab terminal, colab cli, colab ssh, persistent colab, keep colab alive, headless colab, run colab from terminal, colab gpu terminal, colab from vps, colab session keep alive -->
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Why colabapi?
|
|
12
|
+
|
|
13
|
+
Google Colab is fantastic free (and paid) GPU/TPU compute, but it only lives inside a browser tab. Close the tab or lose your connection and the session can go with it. That makes it awkward to:
|
|
14
|
+
|
|
15
|
+
- **demo an MVP** that needs a GPU without renting a server,
|
|
16
|
+
- **reach the runtime from a VPS** or a headless box,
|
|
17
|
+
- **register it as a background service** that stays up, or
|
|
18
|
+
- **watch CPU / GPU / RAM** from a normal terminal.
|
|
19
|
+
|
|
20
|
+
`colabapi` solves this by wrapping **Google's official [`google-colab-cli`](https://github.com/googlecolab/google-colab-cli)** with a friendly single command, a systemd service, a runtime picker, a live resource monitor, and a session time display. You sign in through Google's own browser flow; `colabapi` connects over Google's sanctioned tunnel.
|
|
21
|
+
|
|
22
|
+
## Features
|
|
23
|
+
|
|
24
|
+
- 🔐 **Browser sign in, no password handling.** Authentication happens in Google's own login flow (including 2FA / device checks). `colabapi` never asks for, stores, or transmits your Google credentials.
|
|
25
|
+
- 💻 **Real terminal into the runtime.** `colabapi shell` drops you into a live PTY on the Colab VM. `colabapi repl` gives you a Python REPL.
|
|
26
|
+
- 🎛 **Runtime picker.** List CPU / T4 / L4 / G4 / A100 / H100 / TPU options; paid tier runtimes are clearly flagged as unavailable on a free account.
|
|
27
|
+
- 📈 **Live CPU / GPU / RAM monitor.** `colabapi monitor` streams runtime stats to your terminal (psutil + `nvidia-smi`).
|
|
28
|
+
- ⏱ **Session time display.** See uptime and an estimate of how long before Colab's max lifetime cap.
|
|
29
|
+
- ♻️ **Keepalive that resists the idle timeout.** Google's official daemon does the primary keepalive; `colabapi` adds a supervisory health check.
|
|
30
|
+
- 🧩 **Runs as a Linux service.** `colabapi service install` registers a systemd user service so your session survives logout.
|
|
31
|
+
- 🔎 **Inspectable & MIT licensed.** Read every line. Nothing phones home.
|
|
32
|
+
|
|
33
|
+
## How it works
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
you > colabapi (this tool) > colab (Google's official CLI) > Google's tunnel > your Colab runtime (GPU/TPU VM)
|
|
37
|
+
|
|
38
|
+
colabapi adds: runtime picker, monitor, session timer, systemd service
|
|
39
|
+
colabapi never handles your Google password
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
`colabapi` is an **orchestration and UX layer**. The heavy lifting (OAuth sign in, allocating the runtime, and the encrypted terminal tunnel) is delegated to Google's first party CLI, which is the safe, supported way to do this.
|
|
43
|
+
|
|
44
|
+
## Install
|
|
45
|
+
|
|
46
|
+
**One command installs the whole system.** Google's official Colab CLI is pulled in automatically as a dependency, so you never install it separately.
|
|
47
|
+
|
|
48
|
+
### With pipx (recommended)
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
pipx install colabapi
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### With pip
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pip install --user colabapi
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
> **On Kali / Debian / Ubuntu** you may hit `error: externally-managed-environment` (PEP 668). This is the OS protecting its system Python, not a colabapi problem. Use `pipx` (above), a virtualenv, or override it:
|
|
61
|
+
>
|
|
62
|
+
> ```bash
|
|
63
|
+
> pip install --user colabapi --break-system-packages
|
|
64
|
+
> ```
|
|
65
|
+
|
|
66
|
+
### One line install script
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
curl -fsSL https://raw.githubusercontent.com/lil-limbo/colabapi/main/scripts/install.sh | bash
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### From source
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
git clone https://github.com/lil-limbo/colabapi.git
|
|
76
|
+
cd colabapi
|
|
77
|
+
pip install -e .
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
> **On Kali / Debian / Ubuntu**, `pip install -e .` may fail with `externally-managed-environment` (PEP 668). Pick one:
|
|
81
|
+
>
|
|
82
|
+
> ```bash
|
|
83
|
+
> # Option A: override the guard (quickest)
|
|
84
|
+
> pip install -e . --break-system-packages
|
|
85
|
+
>
|
|
86
|
+
> # Option B: use an isolated virtualenv (cleanest)
|
|
87
|
+
> python3 -m venv .venv && source .venv/bin/activate && pip install -e .
|
|
88
|
+
> ```
|
|
89
|
+
|
|
90
|
+
**Requirement:** Python 3.9+. That's it. Everything else installs with the package.
|
|
91
|
+
|
|
92
|
+
Verify everything is wired up:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
colabapi doctor
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Quickstart
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# 1. Sign in (opens Google's own login in your browser, no password asked)
|
|
102
|
+
colabapi login
|
|
103
|
+
|
|
104
|
+
# 2. Pick a runtime, then name the session when asked
|
|
105
|
+
colabapi run # interactive picker + name prompt
|
|
106
|
+
colabapi run --runtime t4 # or go straight to a T4 GPU
|
|
107
|
+
|
|
108
|
+
# 3. Use it (omit the name to pick from an arrow-key list)
|
|
109
|
+
colabapi shell # terminal on the session, live monitor on top
|
|
110
|
+
colabapi monitor # live CPU / GPU / RAM
|
|
111
|
+
colabapi sessions # list your sessions
|
|
112
|
+
colabapi status # reachability + estimated time remaining
|
|
113
|
+
colabapi stop # stop a session (or: colabapi stop <name>)
|
|
114
|
+
|
|
115
|
+
# 4. Keep it alive after you log out of your server
|
|
116
|
+
colabapi service install
|
|
117
|
+
systemctl --user start colabapi
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Press **Ctrl+C** to leave the monitor; type **`exit`** or press **Ctrl+D** to leave the shell. The Colab runtime keeps running until you stop it or Colab's timers end it.
|
|
121
|
+
|
|
122
|
+
## Command reference
|
|
123
|
+
|
|
124
|
+
| Command | What it does |
|
|
125
|
+
|---|---|
|
|
126
|
+
| `colabapi login` | Sign in via Google's browser flow (no password handled). |
|
|
127
|
+
| `colabapi runtimes` | List runtime types and which need a paid plan. |
|
|
128
|
+
| `colabapi run [--runtime KEY]` | Allocate a runtime and name the session (delegates to `colab new -s NAME`). |
|
|
129
|
+
| `colabapi sessions` | List the sessions colabapi manages. |
|
|
130
|
+
| `colabapi shell [NAME]` | Terminal on a session with a live monitor on top; arrow-key picker if NAME omitted. |
|
|
131
|
+
| `colabapi repl [NAME]` | Interactive Python REPL on a session (`colab repl`). |
|
|
132
|
+
| `colabapi monitor [NAME]` | Live CPU / GPU / RAM monitor for a session. |
|
|
133
|
+
| `colabapi status [NAME]` | Session reachability and estimated time left. |
|
|
134
|
+
| `colabapi stop [NAME]` | Stop a session (`colab stop`); arrow-key picker if NAME omitted. |
|
|
135
|
+
| `colabapi daemon [NAME]` | Supervisory keepalive (used by the service). |
|
|
136
|
+
| `colabapi service install\|uninstall\|status` | Manage the systemd user service. |
|
|
137
|
+
| `colabapi doctor` | Check your environment and the `colab` CLI interface. |
|
|
138
|
+
| `colabapi raw -- <args>` | Passthrough to the official `colab` CLI. |
|
|
139
|
+
|
|
140
|
+
## Running as a Linux service
|
|
141
|
+
|
|
142
|
+
`colabapi` installs as a **systemd user service** (no root required):
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
colabapi service install # writes ~/.config/systemd/user/colabapi.service and enables lingering
|
|
146
|
+
systemctl --user start colabapi
|
|
147
|
+
systemctl --user status colabapi
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Lingering (`loginctl enable-linger`) lets the service keep running after you disconnect from the VPS, which is exactly what you want for an always on demo.
|
|
151
|
+
|
|
152
|
+
## Privacy
|
|
153
|
+
|
|
154
|
+
**We do not capture your login data. We do not collect anything.**
|
|
155
|
+
|
|
156
|
+
- `colabapi` has **no code path that asks for, reads, stores, or transmits your Google password.** Sign in is delegated entirely to Google's official CLI and happens in your own browser under Google's real login flow.
|
|
157
|
+
- `colabapi` operates **no servers**. There is nothing for your data to be sent to. The only network connections are between *your* machine, Google, and (via the official CLI) *your* Colab runtime.
|
|
158
|
+
- The only things written to disk are **plain preferences and session bookkeeping** (which runtime you picked and when), under `~/.config/colabapi` and `~/.local/state/colabapi`.
|
|
159
|
+
- The project is **MIT licensed and fully open source.** [Read the code](https://github.com/lil-limbo/colabapi/tree/main/colabapi). If you don't trust a claim here, verify it in the source. That's the point.
|
|
160
|
+
|
|
161
|
+
## Safety & Colab's limits (please read)
|
|
162
|
+
|
|
163
|
+
`colabapi` deliberately uses **Google's official CLI** instead of the older "SSH into Colab via ngrok/cloudflared" trick, because Colab's own FAQ lists *remote control such as SSH shells* as an activity that can get a runtime (or an account) terminated. Using the sanctioned path is far safer for your Google account.
|
|
164
|
+
|
|
165
|
+
Two limits **nobody** can bypass, and `colabapi` doesn't pretend to:
|
|
166
|
+
|
|
167
|
+
- **Idle timeout (~90 min):** avoided by the keepalive while a session is active.
|
|
168
|
+
- **Absolute max lifetime (~12 h free, up to 24 h paid):** a hard cap. `colabapi` shows an *estimate* of time left, but Google enforces the ceiling.
|
|
169
|
+
|
|
170
|
+
Be a good citizen: don't hold GPU runtimes idle just to reserve them. Aggressive keepalive can get an account flagged.
|
|
171
|
+
|
|
172
|
+
## FAQ
|
|
173
|
+
|
|
174
|
+
**Does colabapi see or store my Google password?**
|
|
175
|
+
No. Sign in is handled by Google's official CLI in your browser. `colabapi` has no password code path at all.
|
|
176
|
+
|
|
177
|
+
**How do I keep a Google Colab session alive after closing the browser?**
|
|
178
|
+
Allocate a runtime with `colabapi run`, then install the service (`colabapi service install`). Google's keepalive holds off the idle timeout; the systemd service keeps `colabapi` supervising it after you log out.
|
|
179
|
+
|
|
180
|
+
**Can I get a terminal / shell into Google Colab?**
|
|
181
|
+
Yes. `colabapi shell` opens a live PTY on the runtime via Google's `colab console`. `colabapi repl` gives a Python REPL.
|
|
182
|
+
|
|
183
|
+
**Can I use a free Colab account?**
|
|
184
|
+
Yes. CPU and T4 GPU runtimes are available on the free tier. Paid runtimes (L4, A100, H100, TPU) are shown but flagged; Colab itself refuses them on free accounts.
|
|
185
|
+
|
|
186
|
+
**How is this different from Google's official `colab` CLI?**
|
|
187
|
+
`colabapi` *uses* the official CLI under the hood and adds a single `colabapi` command, a runtime picker with paid tier flags, a live resource monitor, a session timer, and a ready made systemd service. If you only need raw commands, use `colab` directly; if you want the persistent service demo workflow, use `colabapi`.
|
|
188
|
+
|
|
189
|
+
**Does it work on a VPS / headless server?**
|
|
190
|
+
Yes, that's the main use case. Sign in once in a browser, then run everything from the server, optionally as a systemd service.
|
|
191
|
+
|
|
192
|
+
**Is this affiliated with Google?**
|
|
193
|
+
No. `colabapi` is an independent, open source wrapper. "Google Colab" is a trademark of Google LLC.
|
|
194
|
+
|
|
195
|
+
## Contributing
|
|
196
|
+
|
|
197
|
+
Issues and pull requests welcome. If Google changes the official CLI's flags, the runtime→flag mapping lives in a single file (`colabapi/runtime.py`) and `colabapi doctor` will flag drift.
|
|
198
|
+
|
|
199
|
+
## License
|
|
200
|
+
|
|
201
|
+
MIT. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"""colabapi: run and reach a persistent Google Colab runtime from your own terminal.
|
|
2
|
+
|
|
3
|
+
The tool never handles your Google password. You sign in to Colab in your own
|
|
4
|
+
browser; colabapi connects to the running runtime over a secure tunnel.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
__version__ = "0.1.0"
|