vscode-colab is a Python library that seamlessly connects your Google Colab or Kaggle notebooks to Visual Studio Code (VS Code) using VS Code Remote Tunnels. It allows you to leverage VS Code's powerful editor and extensions while using the computational resources of cloud-based notebooks.
- Secure, Official Integration: Uses official VS Code Remote Tunnels for secure, stable connections.
- GitHub Integration: Automatically authenticated via GitHub, enabling seamless cloning and pushing to private repositories.
- Easy Git Configuration: Optionally configure global Git identity (
user.name
anduser.email
) directly from the library. - Extension Support: Installs essential Python and Jupyter extensions by default; easily customize by passing additional extensions.
- Minimal Setup: Simple and intuitive
login()
andconnect()
functions. - Cross-Platform Compatibility: Fully supports both Google Colab and Kaggle notebooks.
- Interactive UI: Integrated UI within notebooks to manage authentication and tunnel connections easily.
Install the package using pip:
pip install vscode-colab
In your Colab or Kaggle notebook:
import vscode_colab
Authenticate using GitHub credentials:
vscode_colab.login()
Follow the displayed instructions to authorize the connection.
To start the VS Code tunnel, optionally configure Git:
vscode_colab.connect(
name="my-tunnel",
git_user_name="Your Name",
git_user_email="[email protected]"
)
- By default, VS Code Python and Jupyter extensions are installed.
- You can customize the extensions to be installed:
# Add C++ extensions in addition to default ones
vscode_colab.connect(extensions=["ms-vscode.cpptools"])
# Completely override extensions (only install C++ support)
vscode_colab.connect(extensions=["ms-vscode.cpptools"], include_default_extensions=False)
In your local VS Code:
- Ensure the Remote Tunnels extension is installed.
- Sign in with the same GitHub account used in the notebook.
- Open Command Palette (
Ctrl+Shift+P
orCmd+Shift+P
). - Run
Remote Tunnels: Connect to Tunnel...
and select your notebook's tunnel.
You're now seamlessly connected to Colab/Kaggle through VS Code!
By default, vscode-colab
installs the following Visual Studio Code extensions to enhance your Python and Jupyter development experience:
-
Python Path: Facilitates generating internal import statements within a Python project.
-
Black Formatter: Provides code formatting support for Python files using the Black code formatter.
-
isort: Offers import sorting features to improve the readability of your Python code.
-
Python: Adds rich support for the Python language, including IntelliSense, linting, debugging, and more.
-
Pylance: Enhances Python language support with fast, feature-rich language services powered by Pyright.
-
Debugpy: Enables debugging capabilities for Python applications within VS Code.
-
Jupyter: Provides support for Jupyter notebooks, including interactive programming and computing features.
-
Jupyter Keymap: Aligns notebook keybindings in VS Code with those in Jupyter Notebook for a consistent experience.
-
Jupyter Notebook Renderers: Provides renderers for outputs of Jupyter Notebooks, supporting various output formats.
-
TensorBoard: Allows launching and viewing TensorBoards directly within VS Code.
- Notebook Cell Blocking: The
connect()
function maintains an active tunnel connection and will block notebook cell execution. Interrupting the cell or closing the notebook tab will terminate the connection. - Kaggle Clipboard Limitation: On Kaggle, the copy-to-clipboard button will display "Copy Failed" in red due to sandbox restrictions. Manually select and copy the displayed code.
To run tests:
git clone https://github.com/EssenceSentry/vscode-colab.git
cd vscode-colab
pip install -r requirements-dev.txt
pytest
- Configuration via
setup.cfg
- Development dependencies listed in
requirements-dev.txt
- Contributions welcome—open a GitHub issue or PR!
MIT License. See LICENSE.
Special thanks to the developers behind VS Code Remote Tunnels for enabling this seamless remote development experience.