Skip to main content

CLI for interacting with Colab.

Project description

Colab CLI

A command-line interface for Google Colab. Create sessions, run code, manage files, and capture work — all without leaving your terminal.

Why? The agents are coming.

Install

With uv

uv tool install -U google-colab-cli

or with pip

pip install -U google-colab-cli

Note: If you have a non-standard default package index (Googlers), you may also need to add --index https://pypi.org/simple.

Quick start

colab new                              # provision a CPU session
echo "print('hello')" | colab exec     # run code
colab stop                             # release the VM

When only one session is active you can omit -s <session>; the CLI selects it automatically.

Commands

Sessions

Command Description
colab new [-s NAME] [--gpu T4|L4|A100|H100] [--tpu v5e1|v6e1] Provision a new session (CPU by default)
colab sessions List all active sessions on the backend
colab status [-s NAME] Show one session, or all locally-known sessions
colab stop -s NAME Terminate a session
colab url [-s NAME] [--open] Print a browser URL that opens the session in Colab

Execution

Command Description
colab exec [-s NAME] [-f FILE] [--output-image PATH] Run Python from stdin, a .py file, or a .ipynb notebook
colab repl [-s NAME] [--output-image PATH] Interactive Python REPL (or one-shot if stdin is piped)
colab console [-s NAME] Raw TTY shell on the VM (or one-shot if stdin is piped)

Files

Command Description
colab ls [-s NAME] [PATH] List remote files
colab upload -s NAME LOCAL REMOTE Upload a file
colab download -s NAME REMOTE LOCAL Download a file
colab rm -s NAME PATH Delete a remote file
colab edit -s NAME PATH Edit a remote file in $EDITOR

Automation & utility

Command Description
colab auth -s NAME Authenticate the VM for GCP services
colab drivemount -s NAME [PATH] Mount Google Drive (default /content/drive)
colab install -s NAME [-r requirements.txt | pkg ...] Install packages with uv (falls back to pip)
colab log [-s NAME] [-n N] [-o FILE] View or export session history (.ipynb/.md/.txt/.jsonl)
colab pay Open the Colab signup page
colab version Print the installed version
colab update [--install] Check for a newer release (and optionally install it)
colab help Show usage

Global options

  • --auth {oauth2,adc} — authentication strategy (default oauth2)
  • -c, --client-oauth-config PATH — OAuth client config (default ~/.colab-cli-oauth-config.json)
  • --config PATH — session state file (default ~/.config/colab-cli/sessions.json)
  • --logtostderr — send all output to stderr

Examples

# Train a model on an A100, save the checkpoint locally
colab new -s trainer --gpu A100
colab install -s trainer torch transformers
colab exec -s trainer -f train.py
colab download -s trainer checkpoints/model.bin ./model.bin
colab stop -s trainer

# Mount Drive and analyze a notebook
colab new -s analysis
colab drivemount -s analysis
colab exec -s analysis -f analysis.ipynb       # writes analysis_output.ipynb
colab log -s analysis -o report.ipynb
colab stop -s analysis

Notes

  • repl and console require a TTY when run interactively. Pipe stdin to use them in scripts.
  • exec reads files locally and ships their contents to the VM — local edits don't require uploading.
  • Session metadata is stored at ~/.config/colab-cli/sessions.json. Settings (auto-update etc.) live at ~/.config/colab-cli/settings.json.

See CONTRIBUTING.md for how to file feedback.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

google_colab_cli-0.5.7.tar.gz (195.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

google_colab_cli-0.5.7-py3-none-any.whl (61.9 kB view details)

Uploaded Python 3

File details

Details for the file google_colab_cli-0.5.7.tar.gz.

File metadata

  • Download URL: google_colab_cli-0.5.7.tar.gz
  • Upload date:
  • Size: 195.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for google_colab_cli-0.5.7.tar.gz
Algorithm Hash digest
SHA256 91880a3770d3b7722b7456a136884ea84246ffeb7cd9565af6e4f8ef18273a28
MD5 e12bd88815bd75460e6871a57205722d
BLAKE2b-256 a67553319aa5bb0f932e1fbec5722b0d88cbb1f9ea607a69876f9c96c17dbf76

See more details on using hashes here.

Provenance

The following attestation bundles were made for google_colab_cli-0.5.7.tar.gz:

Publisher: google-colab-cli-py@oss-exit-gate-prod.iam.gserviceaccount.com

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.
  • Statement: Publication detail:
    • Token Issuer: https://accounts.google.com
    • Service Account: google-colab-cli-py@oss-exit-gate-prod.iam.gserviceaccount.com

File details

Details for the file google_colab_cli-0.5.7-py3-none-any.whl.

File metadata

File hashes

Hashes for google_colab_cli-0.5.7-py3-none-any.whl
Algorithm Hash digest
SHA256 52ab1bee59ae8ba41831d95e2d9275d179c2c704433b36c0f11b164abb1ef933
MD5 5dc919f118750676e7b3cde4f0df0105
BLAKE2b-256 94eb5a407cd4d4f315861ce5442bdfafb1a2d84943aba82564377c44c3a8789b

See more details on using hashes here.

Provenance

The following attestation bundles were made for google_colab_cli-0.5.7-py3-none-any.whl:

Publisher: google-colab-cli-py@oss-exit-gate-prod.iam.gserviceaccount.com

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.
  • Statement: Publication detail:
    • Token Issuer: https://accounts.google.com
    • Service Account: google-colab-cli-py@oss-exit-gate-prod.iam.gserviceaccount.com

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page