Skip to content
 
 

Latest commit

 

History

34 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

colab-connect

Access Google Colab directly from your local VS Code or Cursor editor using remote tunnels.

Screen.Recording.2023-04-18.at.2.16.16.PM.mp4

Warning

This tool is only allowed by Google Colab's TOS if you are a paid user and have subscription to Colab Pro.

Usage

You can make a copy of this notebook to get started.

On Google Colab, run these cells:

  1. Install the library:
!pip install -U git+https://github.com/KiritoMiao/colab-connect.git

Optional (uv install path):

!command -v uv >/dev/null || curl -LsSf https://astral.sh/uv/install.sh | sh
!uv pip install --system -U git+https://github.com/KiritoMiao/colab-connect.git
  1. Import and start the connector:
from colabconnect import colabconnect

# Default: VS Code editor + VS Code mapper preset
colabconnect()

# Cursor editor + Cursor mapper preset
colabconnect(editor="cursor")

# Persist multiple preset configs
colabconnect(editor="vscode", use_mapper=["vscode", "cursor", "opencode"])

# Add custom persistent mapping: {persistent_subdir: local_path}
colabconnect(
    editor="vscode",
    extra_mappers={"my-tool-cache": "~/.cache/my-tool"},
)

# Override runtime directory (default: Colab Notebooks/runtime)
colabconnect(runtime_dir="/content/drive/MyDrive/Colab Notebooks/my-runtime")

# Optional: use uv and/or create runtime virtualenv explicitly
colabconnect(use_uv=True)
colabconnect(create_venv=True)
colabconnect(use_uv=True, create_venv=True)

Mapper presets

  • use_mapper supports "vscode", "cursor", and "opencode".
  • If use_mapper is not passed, it defaults to [editor].
  • extra_mappers accepts a dict or (name, path) pairs.

Runtime behavior

  • Default runtime directory: /content/drive/MyDrive/Colab Notebooks/runtime.
  • A /colab symlink is created and points to runtime_dir.
  • By default, the connector installs Python tools with pip in the current environment (no virtualenv).
  • Set create_venv=True to create runtime_dir/.venv.
  • Set use_uv=True to use uv for Python tool installation.
  • Tunnel auth is checked first (tunnel user show) and login is skipped when auth is still valid.
  1. After running the code, copy the given code, click the GitHub link and paste the code.

  1. Paste your unique code on the github link and press "Continue".

image

  1. Open your local VSCode Editor. Install the Remote Tunnels extension if you haven't already installed. Then, open the command prompt and select Remote-Tunnels: Connect to Tunnel

image

  1. You will be shown a list of tunnels. Select the first tunnel name that has online beside it.

image

  1. You will be connected to the virtual machine and can access the folders. Open /colab (linked to runtime_dir) and store your code there for persistence on Google Drive. The workflow is similar to the Remote SSH plugin.

image

About

Access Google Colab compute from your local VSCode

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages