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

uv tool install git+https://github.com/googlecolab/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.6.tar.gz (192.9 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.6-py3-none-any.whl (61.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: google_colab_cli-0.5.6.tar.gz
  • Upload date:
  • Size: 192.9 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.6.tar.gz
Algorithm Hash digest
SHA256 4996cb385fbace85d8ab63bb133bdef0b8a06e417239faed8fd687a4c9384795
MD5 6a7cee17bfd8e7342bac2de8c3bd7c9b
BLAKE2b-256 f537651694e9f6b94aec5f561d7db7eb9578e4a6e40d9e577278d540484a6c10

See more details on using hashes here.

Provenance

The following attestation bundles were made for google_colab_cli-0.5.6.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.6-py3-none-any.whl.

File metadata

File hashes

Hashes for google_colab_cli-0.5.6-py3-none-any.whl
Algorithm Hash digest
SHA256 fe5331b48cceb99d2c2f288180aca02bc841c1037d59d334d853810a2806f417
MD5 54b828aa54b76e95f5996046345cfe90
BLAKE2b-256 83ae4d5eb03e462610e3392685e103bbb46bfd9bca9405d8b412b3ba9b7e37ef

See more details on using hashes here.

Provenance

The following attestation bundles were made for google_colab_cli-0.5.6-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