colabapi 0.1.1__tar.gz → 0.2.1__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.2.1/PKG-INFO +333 -0
- colabapi-0.2.1/README.md +301 -0
- {colabapi-0.1.1 → colabapi-0.2.1}/colabapi/__init__.py +1 -1
- colabapi-0.2.1/colabapi/__main__.py +14 -0
- colabapi-0.2.1/colabapi/_colab_shim.py +69 -0
- colabapi-0.2.1/colabapi/_winshim.py +315 -0
- colabapi-0.2.1/colabapi/assets/colabapi.ico +0 -0
- colabapi-0.2.1/colabapi/assets/colabapi.png +0 -0
- {colabapi-0.1.1 → colabapi-0.2.1}/colabapi/cli.py +316 -25
- {colabapi-0.1.1 → colabapi-0.2.1}/colabapi/colabcli.py +54 -10
- {colabapi-0.1.1 → colabapi-0.2.1}/colabapi/config.py +15 -15
- colabapi-0.2.1/colabapi/gui.py +299 -0
- colabapi-0.2.1/colabapi/keepalive.py +203 -0
- colabapi-0.2.1/colabapi/persist.py +94 -0
- colabapi-0.2.1/colabapi/platform.py +87 -0
- colabapi-0.2.1/colabapi/procutil.py +190 -0
- colabapi-0.2.1/colabapi/service.py +180 -0
- {colabapi-0.1.1 → colabapi-0.2.1}/colabapi/shellview.py +24 -8
- colabapi-0.2.1/colabapi/terminal.py +700 -0
- {colabapi-0.1.1 → colabapi-0.2.1}/colabapi/ui.py +48 -7
- colabapi-0.2.1/colabapi/winreg_install.py +237 -0
- colabapi-0.2.1/colabapi.egg-info/PKG-INFO +333 -0
- colabapi-0.2.1/colabapi.egg-info/SOURCES.txt +37 -0
- {colabapi-0.1.1 → colabapi-0.2.1}/colabapi.egg-info/requires.txt +1 -0
- {colabapi-0.1.1 → colabapi-0.2.1}/pyproject.toml +20 -6
- colabapi-0.2.1/tests/test_close_semantics.py +207 -0
- colabapi-0.2.1/tests/test_e2e_console.py +185 -0
- colabapi-0.2.1/tests/test_reconnect.py +107 -0
- colabapi-0.2.1/tests/test_windows_compat.py +164 -0
- colabapi-0.2.1/tests/test_windows_console.py +336 -0
- colabapi-0.2.1/tests/test_windows_encoding.py +66 -0
- colabapi-0.1.1/PKG-INFO +0 -246
- colabapi-0.1.1/README.md +0 -215
- colabapi-0.1.1/colabapi/keepalive.py +0 -64
- colabapi-0.1.1/colabapi/service.py +0 -73
- colabapi-0.1.1/colabapi.egg-info/PKG-INFO +0 -246
- colabapi-0.1.1/colabapi.egg-info/SOURCES.txt +0 -20
- {colabapi-0.1.1 → colabapi-0.2.1}/LICENSE +0 -0
- {colabapi-0.1.1 → colabapi-0.2.1}/colabapi/monitor.py +0 -0
- {colabapi-0.1.1 → colabapi-0.2.1}/colabapi/runtime.py +0 -0
- {colabapi-0.1.1 → colabapi-0.2.1}/colabapi/timing.py +0 -0
- {colabapi-0.1.1 → colabapi-0.2.1}/colabapi.egg-info/dependency_links.txt +0 -0
- {colabapi-0.1.1 → colabapi-0.2.1}/colabapi.egg-info/entry_points.txt +0 -0
- {colabapi-0.1.1 → colabapi-0.2.1}/colabapi.egg-info/top_level.txt +0 -0
- {colabapi-0.1.1 → colabapi-0.2.1}/setup.cfg +0 -0
colabapi-0.2.1/PKG-INFO
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: colabapi
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: Run and keep a Google Colab runtime alive, then reach its terminal from your own server, laptop, or Windows PC. A CLI for headless, persistent Colab sessions -- with Windows support the official CLI does not have.
|
|
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,colab windows,persistent colab,colab keep alive,headless colab,colab runtime,jupyter,gpu,remote terminal,vps,powershell
|
|
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: Operating System :: Microsoft :: Windows
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
|
+
Classifier: Topic :: System :: Distributed Computing
|
|
23
|
+
Classifier: Topic :: Utilities
|
|
24
|
+
Requires-Python: >=3.12
|
|
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: websocket-client>=1.8
|
|
30
|
+
Requires-Dist: google-colab-cli>=0.6.0
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
|
|
33
|
+
# colabapi: a terminal for a persistent Google Colab runtime
|
|
34
|
+
|
|
35
|
+
**Run Google Colab from your own terminal on Linux, macOS, *and Windows*. 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 (with an optional desktop window) 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.
|
|
36
|
+
|
|
37
|
+
> **In one line:** `colabapi` gives you a persistent Colab terminal on your own machine, using Google's official, ban safe sign in and tunnel, and it never sees your Google password.
|
|
38
|
+
|
|
39
|
+
**Two things you only get here:**
|
|
40
|
+
|
|
41
|
+
* 🪟 **It works on Windows.** Google's official Colab CLI is [Linux and macOS only](#windows). It fails on Windows before it can even parse a command. colabapi ships the compatibility layer that makes it run in PowerShell and CMD, and it registers as a real Windows app with its own icon and Start menu entry.
|
|
42
|
+
* 🔌 **It survives a dropped connection.** Google's terminal sets no WebSocket keepalive and has no reconnect, so one blip ends your session. colabapi pings, reconnects with backoff, and keeps your running job alive on the VM.
|
|
43
|
+
|
|
44
|
+
<!-- Keywords: google colab terminal, colab cli, colab ssh, colab windows, colab powershell, persistent colab, keep colab alive, headless colab, run colab from terminal, colab gpu terminal, colab from vps, colab session keep alive, colab gui -->
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Why colabapi?
|
|
49
|
+
|
|
50
|
+
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:
|
|
51
|
+
|
|
52
|
+
* **demo an MVP** that needs a GPU without renting a server,
|
|
53
|
+
* **reach the runtime from a VPS** or a headless box,
|
|
54
|
+
* **register it as a background service** that stays up, or
|
|
55
|
+
* **watch CPU / GPU / RAM** from a normal terminal.
|
|
56
|
+
|
|
57
|
+
`colabapi` solves this by wrapping **Google's official [`google-colab-cli`](https://github.com/googlecolab/google-colab-cli)** with a friendly single command, a graphical window, 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.
|
|
58
|
+
|
|
59
|
+
## Features
|
|
60
|
+
|
|
61
|
+
* 🖥 **A desktop app, not just a CLI.** `colabapi ui` opens a clean graphical window (white, minimal, works on Linux and Windows) with one click access to Login, Run, Shell, Monitor, Sessions, Status, Doctor, and Logout. On Windows it opens straight from the Start menu and the app list.
|
|
62
|
+
* 🪟 **Works on Windows** (PowerShell + CMD), which Google's own CLI does not. Registers as real installed software with its own logo.
|
|
63
|
+
* 🔌 **Reconnects instead of dying.** WebSocket keepalive pings, exponential backoff, and your work keeps running on the VM across the drop.
|
|
64
|
+
* 🔐 **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. `colabapi logout` signs you out again in one command.
|
|
65
|
+
* 💻 **Real terminal into the runtime.** `colabapi shell` drops you into a live shell on the Colab VM. `colabapi repl` gives you a Python REPL.
|
|
66
|
+
* 🎛 **Runtime picker.** List CPU / T4 / L4 / G4 / A100 / H100 / TPU options; paid tier runtimes are clearly flagged as unavailable on a free account.
|
|
67
|
+
* 📈 **Live CPU / GPU / RAM monitor.** `colabapi monitor` streams runtime stats to your terminal (psutil + `nvidia-smi`).
|
|
68
|
+
* ⏱ **Session time display.** See uptime and an estimate of how long before Colab's max lifetime cap.
|
|
69
|
+
* ♻️ **Keepalive that stays up.** Runs Google's own keepalive daemon and restarts it when it dies, which it otherwise does silently.
|
|
70
|
+
* 🧩 **Runs as a background service.** systemd on Linux, a Scheduled Task on Windows, so your session survives logout and reboot.
|
|
71
|
+
* 🔎 **Inspectable & MIT licensed.** Read every line. Nothing phones home.
|
|
72
|
+
|
|
73
|
+
## How it works
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
you > colabapi (this tool) > colab_cli (Google's official CLI) > Google's tunnel > your Colab runtime (GPU/TPU VM)
|
|
77
|
+
|
|
78
|
+
colabapi adds: Windows support, auto-reconnect, keepalive supervision, a desktop
|
|
79
|
+
window, runtime picker, monitor, session timer, background service
|
|
80
|
+
colabapi never handles your Google password
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
`colabapi` is an **orchestration and reliability layer**. The heavy lifting (OAuth sign in, allocating the runtime, and the encrypted tunnel) is delegated to Google's first party CLI, which is the safe, supported way to do this. We do not reimplement any of it; we make it run where it otherwise cannot, and keep it running when it otherwise would not.
|
|
84
|
+
|
|
85
|
+
## Install
|
|
86
|
+
|
|
87
|
+
**One command installs the whole system.** Google's official Colab CLI is pulled in automatically as a dependency, so you never install it separately.
|
|
88
|
+
|
|
89
|
+
### With pipx (recommended)
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
pipx install colabapi
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
<a name="windows"></a>
|
|
96
|
+
### Windows (PowerShell or CMD)
|
|
97
|
+
|
|
98
|
+
> **Google's official Colab CLI does not support Windows at all.** The docs say Linux and macOS only, and on Windows it raises `ImportError: No module named 'termios'` before it can parse a single command. **colabapi fixes that.** It ships a compatibility layer that supplies the POSIX pieces Windows lacks, so Google's CLI runs here unmodified. We patch nothing inside it, so their updates keep working.
|
|
99
|
+
|
|
100
|
+
**One line, in PowerShell:**
|
|
101
|
+
|
|
102
|
+
```powershell
|
|
103
|
+
irm https://raw.githubusercontent.com/lil-limbo/colabapi/v0.2.1/scripts/install.ps1 | iex
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
That finds Python 3.12+ (and offers to install it with winget if you have none), installs Python's `pipx` if needed, installs colabapi, fixes your `PATH`, and registers it with Windows. No administrator rights required. The URL is pinned to the released tag, so you can [read exactly what will run](https://github.com/lil-limbo/colabapi/blob/v0.2.1/scripts/install.ps1) before you run it.
|
|
107
|
+
|
|
108
|
+
**Or by hand** (PowerShell or CMD, identical):
|
|
109
|
+
|
|
110
|
+
```powershell
|
|
111
|
+
python -m pip install --user pipx
|
|
112
|
+
python -m pipx ensurepath
|
|
113
|
+
pipx install colabapi
|
|
114
|
+
colabapi register
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Then **close and reopen your terminal** so `PATH` refreshes, and check it:
|
|
118
|
+
|
|
119
|
+
```powershell
|
|
120
|
+
colabapi doctor
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**`colabapi register`** makes it a real Windows program rather than a loose `.exe`:
|
|
124
|
+
|
|
125
|
+
* it appears in **Settings, Installed apps** (and Add/Remove Programs) with the colabapi logo and a working uninstall entry;
|
|
126
|
+
* a **Start menu** entry opens the colabapi window (`colabapi ui`), and typing **`colabapi`** works from **Win+R**, without touching `PATH`.
|
|
127
|
+
|
|
128
|
+
It writes per-user keys under `HKEY_CURRENT_USER` (so no admin prompt), and `colabapi unregister` removes them, the shortcut, and the icon cleanly.
|
|
129
|
+
|
|
130
|
+
**Requires Python 3.12+** ([`winget install Python.Python.3.13`](https://learn.microsoft.com/en-us/windows/package-manager/winget/)). Works in Windows Terminal, PowerShell 5.1 and 7, and classic `cmd.exe`; ANSI colours are switched on automatically even on legacy consoles.
|
|
131
|
+
|
|
132
|
+
### As root (VPS, container, `sudo -i`)
|
|
133
|
+
|
|
134
|
+
Install system-wide so the command lands in `/usr/local/bin`, which is already on
|
|
135
|
+
root's `PATH`:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
pipx install --global colabapi
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
> **Why:** a plain `pipx install` as root puts the script in `/root/.local/bin`, which
|
|
142
|
+
> most distros do **not** add to root's `PATH`. The install succeeds but you get
|
|
143
|
+
> `colabapi: command not found`. `--global` avoids that. (The one-line install script
|
|
144
|
+
> below detects root and does this for you.)
|
|
145
|
+
|
|
146
|
+
### With pip
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
pip install --user colabapi
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
> **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:
|
|
153
|
+
>
|
|
154
|
+
> ```bash
|
|
155
|
+
> pip install --user colabapi --break-system-packages
|
|
156
|
+
> ```
|
|
157
|
+
|
|
158
|
+
### One line install script
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
curl -fsSL https://raw.githubusercontent.com/lil-limbo/colabapi/main/scripts/install.sh | bash
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### From source
|
|
165
|
+
|
|
166
|
+
No git? Download the ZIP from GitHub ("Code", then "Download ZIP"), unpack it, and run `pip install -e .` inside. With git:
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
git clone https://github.com/lil-limbo/colabapi.git
|
|
170
|
+
cd colabapi
|
|
171
|
+
pip install -e .
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
> **On Kali / Debian / Ubuntu**, `pip install -e .` may fail with `externally-managed-environment` (PEP 668). Pick one:
|
|
175
|
+
>
|
|
176
|
+
> ```bash
|
|
177
|
+
> # Option A: override the guard (quickest)
|
|
178
|
+
> pip install -e . --break-system-packages
|
|
179
|
+
>
|
|
180
|
+
> # Option B: use an isolated virtualenv (cleanest)
|
|
181
|
+
> python3 -m venv .venv && source .venv/bin/activate && pip install -e .
|
|
182
|
+
> ```
|
|
183
|
+
|
|
184
|
+
**Requirement:** Python 3.12+ (Google's `google-colab-cli` requires it). That's it. Everything else installs with the package.
|
|
185
|
+
|
|
186
|
+
Verify everything is wired up:
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
colabapi doctor
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Quickstart
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
# 1. Sign in (opens Google's own login in your browser, no password asked)
|
|
196
|
+
colabapi login
|
|
197
|
+
|
|
198
|
+
# 2. Pick a runtime, then name the session when asked
|
|
199
|
+
colabapi run # interactive picker + name prompt
|
|
200
|
+
colabapi run --runtime t4 # or go straight to a T4 GPU
|
|
201
|
+
|
|
202
|
+
# 3. Use it (omit the name to pick from an arrow-key list)
|
|
203
|
+
colabapi shell # terminal on the session, live monitor on top
|
|
204
|
+
colabapi monitor # live CPU / GPU / RAM
|
|
205
|
+
colabapi sessions # list your sessions
|
|
206
|
+
colabapi status # reachability + estimated time remaining
|
|
207
|
+
colabapi stop # stop a session (or: colabapi stop <name>)
|
|
208
|
+
|
|
209
|
+
# 4. Keep it alive after you log out of your server
|
|
210
|
+
colabapi service install
|
|
211
|
+
systemctl --user start colabapi
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Prefer clicking? `colabapi ui` opens the same actions in a window.
|
|
215
|
+
|
|
216
|
+
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.
|
|
217
|
+
|
|
218
|
+
## The desktop window
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
colabapi ui
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
A minimal white window with the same actions as the CLI: sign in, allocate a runtime, open the shell or the live monitor (each in its own terminal window), and check sessions, status, or doctor output right inside the window. The header shows whether you are signed in and how many sessions are active.
|
|
225
|
+
|
|
226
|
+
* **Windows:** after `colabapi register`, "colabapi" in the Start menu and the app list opens this window directly.
|
|
227
|
+
* **Linux:** the window uses Tkinter, which some distros package separately. If `colabapi ui` says Tkinter is missing, install it with `sudo apt install python3-tk` (Debian / Ubuntu / Kali) or `sudo dnf install python3-tkinter` (Fedora).
|
|
228
|
+
|
|
229
|
+
## Command reference
|
|
230
|
+
|
|
231
|
+
| Command | What it does |
|
|
232
|
+
|---|---|
|
|
233
|
+
| `colabapi ui` | Open the colabapi desktop window (all of the below, with buttons). |
|
|
234
|
+
| `colabapi login` | Sign in via Google's browser flow (no password handled). |
|
|
235
|
+
| `colabapi logout` | Sign out of Google and forget all sessions, for a clean start. |
|
|
236
|
+
| `colabapi runtimes` | List runtime types and which need a paid plan. |
|
|
237
|
+
| `colabapi run [--runtime KEY]` | Allocate a runtime and name the session (delegates to `colab new -s NAME`). |
|
|
238
|
+
| `colabapi sessions` | List the sessions colabapi manages. |
|
|
239
|
+
| `colabapi shell [NAME]` | Terminal on a session with a live monitor on top; arrow-key picker if NAME omitted. |
|
|
240
|
+
| `colabapi repl [NAME]` | Interactive Python REPL on a session (`colab repl`). |
|
|
241
|
+
| `colabapi monitor [NAME]` | Live CPU / GPU / RAM monitor for a session. |
|
|
242
|
+
| `colabapi status [NAME]` | Session reachability and estimated time left. |
|
|
243
|
+
| `colabapi stop [NAME]` | Stop a session (`colab stop`); arrow-key picker if NAME omitted. |
|
|
244
|
+
| `colabapi daemon [NAME]` | Keepalive supervisor: restarts Google's keepalive whenever it dies (used by the service). |
|
|
245
|
+
| `colabapi service install\|uninstall\|status` | Manage the background service (systemd on Linux, Scheduled Task on Windows). |
|
|
246
|
+
| `colabapi register` / `unregister` | **Windows:** add/remove colabapi from Installed apps + Start menu / Win+R. |
|
|
247
|
+
| `colabapi doctor` | Check your environment and the `colab` CLI interface. |
|
|
248
|
+
| `colabapi raw -- <args>` | Passthrough to the official `colab` CLI. |
|
|
249
|
+
|
|
250
|
+
## Running as a background service
|
|
251
|
+
|
|
252
|
+
The service exists to fix a specific hole: Google's keepalive daemon is a child of *your terminal*. Close the laptop, log out of the VPS, or reboot, and it dies, so your runtime idles out even though nothing was actually wrong with it. Registering colabapi with the OS means the keepalive comes back on its own.
|
|
253
|
+
|
|
254
|
+
**Linux**, a systemd **user** service (no root required):
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
colabapi service install # writes ~/.config/systemd/user/colabapi.service and enables lingering
|
|
258
|
+
systemctl --user start colabapi
|
|
259
|
+
systemctl --user status colabapi
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
Lingering (`loginctl enable-linger`) is what lets the service keep running after you disconnect from the VPS, which is exactly what you want for an always-on demo.
|
|
263
|
+
|
|
264
|
+
**Windows**, a **Scheduled Task** that runs at logon (no administrator rights, unlike a true Windows Service):
|
|
265
|
+
|
|
266
|
+
```powershell
|
|
267
|
+
colabapi service install
|
|
268
|
+
schtasks /Run /TN colabapi # start it now; it also starts at every logon
|
|
269
|
+
colabapi service status
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
It appears in Task Scheduler as **colabapi**, and `colabapi service uninstall` removes it.
|
|
273
|
+
|
|
274
|
+
## Privacy
|
|
275
|
+
|
|
276
|
+
**We do not capture your login data. We do not collect anything.**
|
|
277
|
+
|
|
278
|
+
* `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.
|
|
279
|
+
* `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.
|
|
280
|
+
* 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`.
|
|
281
|
+
* Signing out is one command: `colabapi logout` removes the Google token that Google's CLI cached and forgets every session.
|
|
282
|
+
* 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.
|
|
283
|
+
|
|
284
|
+
## Safety (please read)
|
|
285
|
+
|
|
286
|
+
`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.
|
|
287
|
+
|
|
288
|
+
**The keepalive is Google's own.** colabapi doesn't invent a scheme to defeat the idle timeout: it runs the keepalive daemon that ships inside Google's CLI, which pings Colab's own tunnel endpoint once a minute. Our reconnect pings are ordinary WebSocket keepalives on our own socket, standard practice for any long-lived connection, and *not* synthetic activity designed to look like a user who isn't there.
|
|
289
|
+
|
|
290
|
+
Be a good citizen: **don't hold GPU runtimes idle just to reserve them.** Colab's abuse heuristics are real and they do flag paying users. Nothing in colabapi tries to hide what you're doing, and you shouldn't either.
|
|
291
|
+
|
|
292
|
+
## FAQ
|
|
293
|
+
|
|
294
|
+
**Does colabapi see or store my Google password?**
|
|
295
|
+
No. Sign in is handled by Google's official CLI in your browser. `colabapi` has no password code path at all. `colabapi logout` signs you out again whenever you want.
|
|
296
|
+
|
|
297
|
+
**How do I keep a Google Colab session alive after closing the browser?**
|
|
298
|
+
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.
|
|
299
|
+
|
|
300
|
+
**Can I get a terminal / shell into Google Colab?**
|
|
301
|
+
Yes. `colabapi shell` opens a live PTY on the runtime via Google's `colab console`. `colabapi repl` gives a Python REPL.
|
|
302
|
+
|
|
303
|
+
**Is there a graphical interface?**
|
|
304
|
+
Yes. `colabapi ui` opens a desktop window with buttons for every common action, on Linux and Windows. On Windows, `colabapi register` also puts it in the Start menu and the app list, so you can open it like any other program.
|
|
305
|
+
|
|
306
|
+
**Can I use a free Colab account?**
|
|
307
|
+
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.
|
|
308
|
+
|
|
309
|
+
**How is this different from Google's official `colab` CLI?**
|
|
310
|
+
`colabapi` *uses* the official CLI under the hood, and adds the things it doesn't do: **it runs on Windows** (the official one cannot), **it reconnects when the network drops** (the official one has no keepalive and no retry), and it keeps the keepalive daemon alive across logout and reboot. On top of that: one `colabapi` command, a desktop window, a runtime picker with paid tier flags, a live resource monitor, a session timer, and a ready-made background service. If you only need raw commands on Linux, use `colab` directly.
|
|
311
|
+
|
|
312
|
+
**Does colabapi work on Windows? Google says its CLI doesn't.**
|
|
313
|
+
Yes, that's one of the two reasons this project exists. Google's CLI imports `termios`, a POSIX-only module, at startup, so on Windows it dies before running any command at all. colabapi supplies the missing pieces through the Win32 console API, so Google's CLI runs unmodified in PowerShell and CMD. We don't patch their code, so their updates keep working. See [Windows](#windows).
|
|
314
|
+
|
|
315
|
+
**My session keeps dying. Is that Colab or colabapi?**
|
|
316
|
+
Usually neither: it's the *connection*, not the runtime. colabapi's reconnect and keepalive supervision exist exactly for that, and the hard limits that remain (Colab's idle timeout and max lifetime cap) are enforced server-side and shown by `colabapi status`.
|
|
317
|
+
|
|
318
|
+
**What happens to my running job if my Wi-Fi drops?**
|
|
319
|
+
It keeps running. Your shell lives inside a tmux session on the Colab VM, so the job is not attached to your connection; colabapi reconnects and puts you back in front of it. You can also detach on purpose with **Ctrl+]**.
|
|
320
|
+
|
|
321
|
+
**Does it work on a VPS / headless server?**
|
|
322
|
+
Yes, that's the main use case. Sign in once in a browser, then run everything from the server, optionally as a systemd service.
|
|
323
|
+
|
|
324
|
+
**Is this affiliated with Google?**
|
|
325
|
+
No. `colabapi` is an independent, open source wrapper. "Google Colab" is a trademark of Google LLC.
|
|
326
|
+
|
|
327
|
+
## Contributing
|
|
328
|
+
|
|
329
|
+
Issues and pull requests welcome. If Google changes the official CLI's flags, the mapping from runtime to flag lives in a single file (`colabapi/runtime.py`) and `colabapi doctor` will flag drift.
|
|
330
|
+
|
|
331
|
+
## License
|
|
332
|
+
|
|
333
|
+
MIT. See [LICENSE](LICENSE).
|
colabapi-0.2.1/README.md
ADDED
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
# colabapi: a terminal for a persistent Google Colab runtime
|
|
2
|
+
|
|
3
|
+
**Run Google Colab from your own terminal on Linux, macOS, *and Windows*. 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 (with an optional desktop window) 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 machine, using Google's official, ban safe sign in and tunnel, and it never sees your Google password.
|
|
6
|
+
|
|
7
|
+
**Two things you only get here:**
|
|
8
|
+
|
|
9
|
+
* 🪟 **It works on Windows.** Google's official Colab CLI is [Linux and macOS only](#windows). It fails on Windows before it can even parse a command. colabapi ships the compatibility layer that makes it run in PowerShell and CMD, and it registers as a real Windows app with its own icon and Start menu entry.
|
|
10
|
+
* 🔌 **It survives a dropped connection.** Google's terminal sets no WebSocket keepalive and has no reconnect, so one blip ends your session. colabapi pings, reconnects with backoff, and keeps your running job alive on the VM.
|
|
11
|
+
|
|
12
|
+
<!-- Keywords: google colab terminal, colab cli, colab ssh, colab windows, colab powershell, persistent colab, keep colab alive, headless colab, run colab from terminal, colab gpu terminal, colab from vps, colab session keep alive, colab gui -->
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Why colabapi?
|
|
17
|
+
|
|
18
|
+
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:
|
|
19
|
+
|
|
20
|
+
* **demo an MVP** that needs a GPU without renting a server,
|
|
21
|
+
* **reach the runtime from a VPS** or a headless box,
|
|
22
|
+
* **register it as a background service** that stays up, or
|
|
23
|
+
* **watch CPU / GPU / RAM** from a normal terminal.
|
|
24
|
+
|
|
25
|
+
`colabapi` solves this by wrapping **Google's official [`google-colab-cli`](https://github.com/googlecolab/google-colab-cli)** with a friendly single command, a graphical window, 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.
|
|
26
|
+
|
|
27
|
+
## Features
|
|
28
|
+
|
|
29
|
+
* 🖥 **A desktop app, not just a CLI.** `colabapi ui` opens a clean graphical window (white, minimal, works on Linux and Windows) with one click access to Login, Run, Shell, Monitor, Sessions, Status, Doctor, and Logout. On Windows it opens straight from the Start menu and the app list.
|
|
30
|
+
* 🪟 **Works on Windows** (PowerShell + CMD), which Google's own CLI does not. Registers as real installed software with its own logo.
|
|
31
|
+
* 🔌 **Reconnects instead of dying.** WebSocket keepalive pings, exponential backoff, and your work keeps running on the VM across the drop.
|
|
32
|
+
* 🔐 **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. `colabapi logout` signs you out again in one command.
|
|
33
|
+
* 💻 **Real terminal into the runtime.** `colabapi shell` drops you into a live shell on the Colab VM. `colabapi repl` gives you a Python REPL.
|
|
34
|
+
* 🎛 **Runtime picker.** List CPU / T4 / L4 / G4 / A100 / H100 / TPU options; paid tier runtimes are clearly flagged as unavailable on a free account.
|
|
35
|
+
* 📈 **Live CPU / GPU / RAM monitor.** `colabapi monitor` streams runtime stats to your terminal (psutil + `nvidia-smi`).
|
|
36
|
+
* ⏱ **Session time display.** See uptime and an estimate of how long before Colab's max lifetime cap.
|
|
37
|
+
* ♻️ **Keepalive that stays up.** Runs Google's own keepalive daemon and restarts it when it dies, which it otherwise does silently.
|
|
38
|
+
* 🧩 **Runs as a background service.** systemd on Linux, a Scheduled Task on Windows, so your session survives logout and reboot.
|
|
39
|
+
* 🔎 **Inspectable & MIT licensed.** Read every line. Nothing phones home.
|
|
40
|
+
|
|
41
|
+
## How it works
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
you > colabapi (this tool) > colab_cli (Google's official CLI) > Google's tunnel > your Colab runtime (GPU/TPU VM)
|
|
45
|
+
|
|
46
|
+
colabapi adds: Windows support, auto-reconnect, keepalive supervision, a desktop
|
|
47
|
+
window, runtime picker, monitor, session timer, background service
|
|
48
|
+
colabapi never handles your Google password
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
`colabapi` is an **orchestration and reliability layer**. The heavy lifting (OAuth sign in, allocating the runtime, and the encrypted tunnel) is delegated to Google's first party CLI, which is the safe, supported way to do this. We do not reimplement any of it; we make it run where it otherwise cannot, and keep it running when it otherwise would not.
|
|
52
|
+
|
|
53
|
+
## Install
|
|
54
|
+
|
|
55
|
+
**One command installs the whole system.** Google's official Colab CLI is pulled in automatically as a dependency, so you never install it separately.
|
|
56
|
+
|
|
57
|
+
### With pipx (recommended)
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pipx install colabapi
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
<a name="windows"></a>
|
|
64
|
+
### Windows (PowerShell or CMD)
|
|
65
|
+
|
|
66
|
+
> **Google's official Colab CLI does not support Windows at all.** The docs say Linux and macOS only, and on Windows it raises `ImportError: No module named 'termios'` before it can parse a single command. **colabapi fixes that.** It ships a compatibility layer that supplies the POSIX pieces Windows lacks, so Google's CLI runs here unmodified. We patch nothing inside it, so their updates keep working.
|
|
67
|
+
|
|
68
|
+
**One line, in PowerShell:**
|
|
69
|
+
|
|
70
|
+
```powershell
|
|
71
|
+
irm https://raw.githubusercontent.com/lil-limbo/colabapi/v0.2.1/scripts/install.ps1 | iex
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
That finds Python 3.12+ (and offers to install it with winget if you have none), installs Python's `pipx` if needed, installs colabapi, fixes your `PATH`, and registers it with Windows. No administrator rights required. The URL is pinned to the released tag, so you can [read exactly what will run](https://github.com/lil-limbo/colabapi/blob/v0.2.1/scripts/install.ps1) before you run it.
|
|
75
|
+
|
|
76
|
+
**Or by hand** (PowerShell or CMD, identical):
|
|
77
|
+
|
|
78
|
+
```powershell
|
|
79
|
+
python -m pip install --user pipx
|
|
80
|
+
python -m pipx ensurepath
|
|
81
|
+
pipx install colabapi
|
|
82
|
+
colabapi register
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Then **close and reopen your terminal** so `PATH` refreshes, and check it:
|
|
86
|
+
|
|
87
|
+
```powershell
|
|
88
|
+
colabapi doctor
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**`colabapi register`** makes it a real Windows program rather than a loose `.exe`:
|
|
92
|
+
|
|
93
|
+
* it appears in **Settings, Installed apps** (and Add/Remove Programs) with the colabapi logo and a working uninstall entry;
|
|
94
|
+
* a **Start menu** entry opens the colabapi window (`colabapi ui`), and typing **`colabapi`** works from **Win+R**, without touching `PATH`.
|
|
95
|
+
|
|
96
|
+
It writes per-user keys under `HKEY_CURRENT_USER` (so no admin prompt), and `colabapi unregister` removes them, the shortcut, and the icon cleanly.
|
|
97
|
+
|
|
98
|
+
**Requires Python 3.12+** ([`winget install Python.Python.3.13`](https://learn.microsoft.com/en-us/windows/package-manager/winget/)). Works in Windows Terminal, PowerShell 5.1 and 7, and classic `cmd.exe`; ANSI colours are switched on automatically even on legacy consoles.
|
|
99
|
+
|
|
100
|
+
### As root (VPS, container, `sudo -i`)
|
|
101
|
+
|
|
102
|
+
Install system-wide so the command lands in `/usr/local/bin`, which is already on
|
|
103
|
+
root's `PATH`:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
pipx install --global colabapi
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
> **Why:** a plain `pipx install` as root puts the script in `/root/.local/bin`, which
|
|
110
|
+
> most distros do **not** add to root's `PATH`. The install succeeds but you get
|
|
111
|
+
> `colabapi: command not found`. `--global` avoids that. (The one-line install script
|
|
112
|
+
> below detects root and does this for you.)
|
|
113
|
+
|
|
114
|
+
### With pip
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
pip install --user colabapi
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
> **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:
|
|
121
|
+
>
|
|
122
|
+
> ```bash
|
|
123
|
+
> pip install --user colabapi --break-system-packages
|
|
124
|
+
> ```
|
|
125
|
+
|
|
126
|
+
### One line install script
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
curl -fsSL https://raw.githubusercontent.com/lil-limbo/colabapi/main/scripts/install.sh | bash
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### From source
|
|
133
|
+
|
|
134
|
+
No git? Download the ZIP from GitHub ("Code", then "Download ZIP"), unpack it, and run `pip install -e .` inside. With git:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
git clone https://github.com/lil-limbo/colabapi.git
|
|
138
|
+
cd colabapi
|
|
139
|
+
pip install -e .
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
> **On Kali / Debian / Ubuntu**, `pip install -e .` may fail with `externally-managed-environment` (PEP 668). Pick one:
|
|
143
|
+
>
|
|
144
|
+
> ```bash
|
|
145
|
+
> # Option A: override the guard (quickest)
|
|
146
|
+
> pip install -e . --break-system-packages
|
|
147
|
+
>
|
|
148
|
+
> # Option B: use an isolated virtualenv (cleanest)
|
|
149
|
+
> python3 -m venv .venv && source .venv/bin/activate && pip install -e .
|
|
150
|
+
> ```
|
|
151
|
+
|
|
152
|
+
**Requirement:** Python 3.12+ (Google's `google-colab-cli` requires it). That's it. Everything else installs with the package.
|
|
153
|
+
|
|
154
|
+
Verify everything is wired up:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
colabapi doctor
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Quickstart
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
# 1. Sign in (opens Google's own login in your browser, no password asked)
|
|
164
|
+
colabapi login
|
|
165
|
+
|
|
166
|
+
# 2. Pick a runtime, then name the session when asked
|
|
167
|
+
colabapi run # interactive picker + name prompt
|
|
168
|
+
colabapi run --runtime t4 # or go straight to a T4 GPU
|
|
169
|
+
|
|
170
|
+
# 3. Use it (omit the name to pick from an arrow-key list)
|
|
171
|
+
colabapi shell # terminal on the session, live monitor on top
|
|
172
|
+
colabapi monitor # live CPU / GPU / RAM
|
|
173
|
+
colabapi sessions # list your sessions
|
|
174
|
+
colabapi status # reachability + estimated time remaining
|
|
175
|
+
colabapi stop # stop a session (or: colabapi stop <name>)
|
|
176
|
+
|
|
177
|
+
# 4. Keep it alive after you log out of your server
|
|
178
|
+
colabapi service install
|
|
179
|
+
systemctl --user start colabapi
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Prefer clicking? `colabapi ui` opens the same actions in a window.
|
|
183
|
+
|
|
184
|
+
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.
|
|
185
|
+
|
|
186
|
+
## The desktop window
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
colabapi ui
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
A minimal white window with the same actions as the CLI: sign in, allocate a runtime, open the shell or the live monitor (each in its own terminal window), and check sessions, status, or doctor output right inside the window. The header shows whether you are signed in and how many sessions are active.
|
|
193
|
+
|
|
194
|
+
* **Windows:** after `colabapi register`, "colabapi" in the Start menu and the app list opens this window directly.
|
|
195
|
+
* **Linux:** the window uses Tkinter, which some distros package separately. If `colabapi ui` says Tkinter is missing, install it with `sudo apt install python3-tk` (Debian / Ubuntu / Kali) or `sudo dnf install python3-tkinter` (Fedora).
|
|
196
|
+
|
|
197
|
+
## Command reference
|
|
198
|
+
|
|
199
|
+
| Command | What it does |
|
|
200
|
+
|---|---|
|
|
201
|
+
| `colabapi ui` | Open the colabapi desktop window (all of the below, with buttons). |
|
|
202
|
+
| `colabapi login` | Sign in via Google's browser flow (no password handled). |
|
|
203
|
+
| `colabapi logout` | Sign out of Google and forget all sessions, for a clean start. |
|
|
204
|
+
| `colabapi runtimes` | List runtime types and which need a paid plan. |
|
|
205
|
+
| `colabapi run [--runtime KEY]` | Allocate a runtime and name the session (delegates to `colab new -s NAME`). |
|
|
206
|
+
| `colabapi sessions` | List the sessions colabapi manages. |
|
|
207
|
+
| `colabapi shell [NAME]` | Terminal on a session with a live monitor on top; arrow-key picker if NAME omitted. |
|
|
208
|
+
| `colabapi repl [NAME]` | Interactive Python REPL on a session (`colab repl`). |
|
|
209
|
+
| `colabapi monitor [NAME]` | Live CPU / GPU / RAM monitor for a session. |
|
|
210
|
+
| `colabapi status [NAME]` | Session reachability and estimated time left. |
|
|
211
|
+
| `colabapi stop [NAME]` | Stop a session (`colab stop`); arrow-key picker if NAME omitted. |
|
|
212
|
+
| `colabapi daemon [NAME]` | Keepalive supervisor: restarts Google's keepalive whenever it dies (used by the service). |
|
|
213
|
+
| `colabapi service install\|uninstall\|status` | Manage the background service (systemd on Linux, Scheduled Task on Windows). |
|
|
214
|
+
| `colabapi register` / `unregister` | **Windows:** add/remove colabapi from Installed apps + Start menu / Win+R. |
|
|
215
|
+
| `colabapi doctor` | Check your environment and the `colab` CLI interface. |
|
|
216
|
+
| `colabapi raw -- <args>` | Passthrough to the official `colab` CLI. |
|
|
217
|
+
|
|
218
|
+
## Running as a background service
|
|
219
|
+
|
|
220
|
+
The service exists to fix a specific hole: Google's keepalive daemon is a child of *your terminal*. Close the laptop, log out of the VPS, or reboot, and it dies, so your runtime idles out even though nothing was actually wrong with it. Registering colabapi with the OS means the keepalive comes back on its own.
|
|
221
|
+
|
|
222
|
+
**Linux**, a systemd **user** service (no root required):
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
colabapi service install # writes ~/.config/systemd/user/colabapi.service and enables lingering
|
|
226
|
+
systemctl --user start colabapi
|
|
227
|
+
systemctl --user status colabapi
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Lingering (`loginctl enable-linger`) is what lets the service keep running after you disconnect from the VPS, which is exactly what you want for an always-on demo.
|
|
231
|
+
|
|
232
|
+
**Windows**, a **Scheduled Task** that runs at logon (no administrator rights, unlike a true Windows Service):
|
|
233
|
+
|
|
234
|
+
```powershell
|
|
235
|
+
colabapi service install
|
|
236
|
+
schtasks /Run /TN colabapi # start it now; it also starts at every logon
|
|
237
|
+
colabapi service status
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
It appears in Task Scheduler as **colabapi**, and `colabapi service uninstall` removes it.
|
|
241
|
+
|
|
242
|
+
## Privacy
|
|
243
|
+
|
|
244
|
+
**We do not capture your login data. We do not collect anything.**
|
|
245
|
+
|
|
246
|
+
* `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.
|
|
247
|
+
* `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.
|
|
248
|
+
* 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`.
|
|
249
|
+
* Signing out is one command: `colabapi logout` removes the Google token that Google's CLI cached and forgets every session.
|
|
250
|
+
* 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.
|
|
251
|
+
|
|
252
|
+
## Safety (please read)
|
|
253
|
+
|
|
254
|
+
`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.
|
|
255
|
+
|
|
256
|
+
**The keepalive is Google's own.** colabapi doesn't invent a scheme to defeat the idle timeout: it runs the keepalive daemon that ships inside Google's CLI, which pings Colab's own tunnel endpoint once a minute. Our reconnect pings are ordinary WebSocket keepalives on our own socket, standard practice for any long-lived connection, and *not* synthetic activity designed to look like a user who isn't there.
|
|
257
|
+
|
|
258
|
+
Be a good citizen: **don't hold GPU runtimes idle just to reserve them.** Colab's abuse heuristics are real and they do flag paying users. Nothing in colabapi tries to hide what you're doing, and you shouldn't either.
|
|
259
|
+
|
|
260
|
+
## FAQ
|
|
261
|
+
|
|
262
|
+
**Does colabapi see or store my Google password?**
|
|
263
|
+
No. Sign in is handled by Google's official CLI in your browser. `colabapi` has no password code path at all. `colabapi logout` signs you out again whenever you want.
|
|
264
|
+
|
|
265
|
+
**How do I keep a Google Colab session alive after closing the browser?**
|
|
266
|
+
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.
|
|
267
|
+
|
|
268
|
+
**Can I get a terminal / shell into Google Colab?**
|
|
269
|
+
Yes. `colabapi shell` opens a live PTY on the runtime via Google's `colab console`. `colabapi repl` gives a Python REPL.
|
|
270
|
+
|
|
271
|
+
**Is there a graphical interface?**
|
|
272
|
+
Yes. `colabapi ui` opens a desktop window with buttons for every common action, on Linux and Windows. On Windows, `colabapi register` also puts it in the Start menu and the app list, so you can open it like any other program.
|
|
273
|
+
|
|
274
|
+
**Can I use a free Colab account?**
|
|
275
|
+
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.
|
|
276
|
+
|
|
277
|
+
**How is this different from Google's official `colab` CLI?**
|
|
278
|
+
`colabapi` *uses* the official CLI under the hood, and adds the things it doesn't do: **it runs on Windows** (the official one cannot), **it reconnects when the network drops** (the official one has no keepalive and no retry), and it keeps the keepalive daemon alive across logout and reboot. On top of that: one `colabapi` command, a desktop window, a runtime picker with paid tier flags, a live resource monitor, a session timer, and a ready-made background service. If you only need raw commands on Linux, use `colab` directly.
|
|
279
|
+
|
|
280
|
+
**Does colabapi work on Windows? Google says its CLI doesn't.**
|
|
281
|
+
Yes, that's one of the two reasons this project exists. Google's CLI imports `termios`, a POSIX-only module, at startup, so on Windows it dies before running any command at all. colabapi supplies the missing pieces through the Win32 console API, so Google's CLI runs unmodified in PowerShell and CMD. We don't patch their code, so their updates keep working. See [Windows](#windows).
|
|
282
|
+
|
|
283
|
+
**My session keeps dying. Is that Colab or colabapi?**
|
|
284
|
+
Usually neither: it's the *connection*, not the runtime. colabapi's reconnect and keepalive supervision exist exactly for that, and the hard limits that remain (Colab's idle timeout and max lifetime cap) are enforced server-side and shown by `colabapi status`.
|
|
285
|
+
|
|
286
|
+
**What happens to my running job if my Wi-Fi drops?**
|
|
287
|
+
It keeps running. Your shell lives inside a tmux session on the Colab VM, so the job is not attached to your connection; colabapi reconnects and puts you back in front of it. You can also detach on purpose with **Ctrl+]**.
|
|
288
|
+
|
|
289
|
+
**Does it work on a VPS / headless server?**
|
|
290
|
+
Yes, that's the main use case. Sign in once in a browser, then run everything from the server, optionally as a systemd service.
|
|
291
|
+
|
|
292
|
+
**Is this affiliated with Google?**
|
|
293
|
+
No. `colabapi` is an independent, open source wrapper. "Google Colab" is a trademark of Google LLC.
|
|
294
|
+
|
|
295
|
+
## Contributing
|
|
296
|
+
|
|
297
|
+
Issues and pull requests welcome. If Google changes the official CLI's flags, the mapping from runtime to flag lives in a single file (`colabapi/runtime.py`) and `colabapi doctor` will flag drift.
|
|
298
|
+
|
|
299
|
+
## License
|
|
300
|
+
|
|
301
|
+
MIT. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""Make `python -m colabapi` equivalent to the `colabapi` command.
|
|
2
|
+
|
|
3
|
+
The console script is the normal entry point, but `python -m colabapi` is what
|
|
4
|
+
works when the scripts directory is not on PATH (a fresh install before the
|
|
5
|
+
shell restarts, a venv driven by absolute path, a subprocess that only knows
|
|
6
|
+
the interpreter). Same main(), same behaviour.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from .cli import main
|
|
12
|
+
|
|
13
|
+
if __name__ == "__main__":
|
|
14
|
+
main()
|