cotop
top for Google Colab: compute units, runtimes and what they cost, live in your terminal.
- Your account: compute units left, the hourly rate, when you run out, and the rate over the last day. Compute units left turn red when they run out within a day.
- Runtimes: every VM on your account, most expensive first, including ones opened in a browser, with a live GPU sparkline, rate, spend, uptime and state. A runtime idle while it bills, out of RAM or disk, or unreachable says so in its row.
- The selected runtime: a braille graph of GPU utilization, read every two seconds, with VRAM, RAM and disk meters, what it has cost and its recent activity. On a runtime without a GPU, the graph shows RAM.
- History: press
hfor past sessions, how long each ran and roughly what it cost. - Actions: stop a runtime, restart its kernel, or open a shell on it.
cotop works on top of the official Colab CLI. It uses the CLI's sign-in, session names and history, so runtimes you start with colab new show up by name.
Install
uv tool install cotop
cotop
cotop --demo # a made-up account with twelve runtimes; no sign-in
cotop needs Python 3.12 or later. It is tested on macOS and should work on Linux. If you have not signed in to the Colab CLI yet, cotop runs the same Google sign-in on first launch. On macOS, Keychain may ask once whether cotop's Python can read the Colab CLI's token.
Keys
| Key | Action |
|---|---|
↑ ↓ or k j |
Select a runtime |
h |
Past sessions and the hardware your account can use |
r |
Refresh now (cotop also refreshes every 15 seconds) |
s |
Stop the selected runtime |
R |
Restart its kernel |
x |
Open a shell on it with colab ssh |
? |
Show every key |
q |
Quit |
Stop and restart ask first, and Cancel has focus. colab ssh looks for ~/.ssh/id_ed25519.pub or ~/.ssh/id_ecdsa.pub. For another key, start cotop with cotop -i ~/.ssh/KEY.pub. Restart and ssh work only on runtimes started with the Colab CLI. Stop works on any runtime.
Which numbers are estimates
Colab reports one hourly rate for the whole account, not one per runtime. cotop shows a per-runtime rate as follows:
- With one runtime, the rate is exact.
- With several runtimes on the same hardware, cotop splits the total evenly.
- Otherwise cotop uses a rate it learned earlier, when only that hardware was running. These rates are stored in
~/.cache/cotop/rates.json. - With no learned rate, the column shows
?.
Estimates start with ≈, and upper bounds start with ≤. Colab boots VMs before it assigns them, so uptime and spend count from the assignment time in the CLI's history. A runtime opened in a browser has no assignment time, so cotop counts from VM boot and shows an upper bound.
docs/data-sources.md lists each request cotop makes and what it reads.
What cotop can touch
cotop signs in with the Colab CLI's own credentials, so it can do anything colab can, with the access you granted when you signed in. It adds no credentials of its own.
Guarantees
Each line is true of this release and names the test on main that checks it:
- Before it stops, restarts or opens a shell on a named runtime, cotop checks that the name still points at the runtime you selected (
test_every_named_action_checks_the_name_still_means_this_runtime). - No module in
src/cotopother thancolab_cli_calls.pyhas an import statement forgoogle-colab-cli, or writes_session(the attribute that holds the signed-in session) as an attribute or a string literal (test_only_the_handoff_module_imports_colab_cli_or_touches_the_session). - A runtime's proxy token never follows a redirect (
test_the_proxy_token_never_follows_a_redirect). - From the CLI's history, cotop never shows code, outputs or prompt replies (
test_history_never_surfaces_code_outputs_or_stdin).
What cotop does in this release
- It sends GET requests through the CLI's signed-in session: to
colab.research.google.comfor the balance and the runtime list, and to Google's userinfo endpoint for your email address. - It sends GET requests to each runtime's proxy, at the URL Colab returns for it, with that runtime's proxy token.
- It reads the CLI's history files in
~/.config/colab-cli/history/and the CLI's session list. - It writes learned rates and balance samples to
~/.cache/cotop/. - For a runtime the CLI started, it runs
colab stop -s NAMEorcolab restart-kernel -s NAMEwhen you presssorRand confirm, andcolab ssh -s NAME [-i KEY]in your terminal when you pressx. cotop --demoreturns frommain()beforesign_inand runs on the made-up account insrc/cotop/demo.py, with its cache in a temporary directory (run_demo).
docs/data-sources.md gives each request and how often cotop sends it.
Calls into the Colab CLI
src/cotop/colab_cli_calls.py hands these calls to google-colab-cli:
sign_incalls the CLI'sget_credentials()at start. It returns aGoogle, which keeps the session private and offers two calls:Google.getsends a GET through the session. When the session's access token expires, the session refreshes it with a POST.Google.unassigncalls the CLI client'sunassign, to stop a runtime the CLI didn't start.
named_sessionscalls the CLI'sStateStore(path).list(), once~/.config/colab-cli/sessions.jsonexists.colab_argvbuilds thecolabcommand lines described above.
What these calls read, write and send inside the CLI is the CLI's behavior.
What the CLI does (0.8.0; not a complete list)
These examples are taken from google-colab-cli 0.8.0:
get_credentials()reads and writes the OS keyring. It moves an old plaintext~/.config/colab-cli/token.jsoninto the keyring, and reads~/.colab-cli-oauth-config.jsonif that file exists.- The three
colabcommands cotop runs log to~/.config/colab-cli/colab.logwith secrets redacted, update files under~/.config/colab-cli/, and checkpypi.orgfor an update at most once a day. colab sshreads your SSH public key.
Not affiliated with Google
cotop is an independent project. It relies on internal parts of google-colab-cli and on Colab endpoints that are not public APIs. Either can change without notice. cotop pins the Colab CLI's minor version for that reason.
Development
uv sync
uv run pytest
uv run python scripts/screenshots.py OUT_DIR # README screenshots, rendered from the demo account
To release, set version in pyproject.toml, then push a matching tag such as v0.1.0. The publish workflow builds the package and uploads it to PyPI with trusted publishing.
License
Metadata
Release files for cotop 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cotop-0.3.0.tar.gz | 3.4 MB | Without provenance | Details for cotop-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cotop-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for cotop-0.3.0-py3-none-any.whl |
Total release size: 3.4 MB
Release files / cotop-0.3.0.tar.gz
| Download URL | cotop-0.3.0.tar.gz |
|---|---|
| Size | 3.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2c374292c9de75e8a784ab5c189ccc3d9030a28454d51797f4ac36b8f8fdb6f8
|
|
BLAKE2b-256 checksum How to use checksums |
d8f0517f72402c975c42b4b35ca96d97b191d9a52c138578895149c8491391bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / cotop-0.3.0-py3-none-any.whl
| Download URL | cotop-0.3.0-py3-none-any.whl |
|---|---|
| Size | 33.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a7dfecdd09cba7d545cd53cb98334d5130fb18b2cae0c688fe29f41cd27dc9f9
|
|
BLAKE2b-256 checksum How to use checksums |
94f1720e6ab240744070f4b436c6b7d84eb77692518419daf1cac35bbe6e45be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for cotop 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.