-
Notifications
You must be signed in to change notification settings - Fork 50
User Guide
Provision your first server by opening a notebook (.ipynb), clicking Select Kernel in the top right and selecting Colab.
Either Auto Connect to a default Colab server or select New Colab Server to provision a specific machine type.
When prompted to sign in using Google, select Allow. You may be prompted to allow VS Code to open external links. Once you consent, your browser will open and you can select the account you wish to use and complete the OAuth sign-in flow.
Upon signing in, you should be automatically redirected back to VS Code. Depending on whether you have previously allowed your browser and VS Code to open links, you may be prompted before automatic redirection.
Once signed in, select the kernel you'd like to connect to.
Write some code!
A server can be removed by either:
- Opening the command palette (
[Ctrl|Cmd]+Shift+P) and invoking theColab: Remove Servercommand, or - Clicking the Colab button at the top of the notebook and selecting Remove Server.
Decided you want a different machine type? Doing work in parallel across notebooks? A new server can be provisioned by following the same steps detailed above (in the Hello World 🌎 section) and selecting the New Colab Server option.
To get started, you may either:
- Open the command palette (
[Ctrl|Cmd]+Shift+P) and invoke theColab: Mount Google Drive to Server...command, or - Click the Colab button at the top of the notebook and select Mount Google Drive to Server.
This will insert a new cell into your notebook with the snippet to execute Drive mounting:
Drive.mount.demo.for.wiki.webm
Are you coming from using Colab on the web? Learn about some of the differences and parallels between Colab on the web and Colab in VS Code.
When you go to https://colab.research.google.com/, you write some code, click ▶ and it auto-magically works! For a majority of Colab users, that simplicity is exactly what they want and love. This auto-magical executor of code is referred to as a Runtime in Colab on the web. In order to best understand how Colab's exposed in VS Code, the following terms are defined:
- A Jupyter Server: this core backend application that orchestrates the entire notebook experience. The intermediary between the notebook frontend (e.g. the Colab website or the VS Code notebook) and the computation engine (kernels).
- A Kernel: the computation engine that executes notebook code. When you click ▶ on a cell, that code is sent to a kernel which returns the output back to the server to be displayed in the notebook. Kernels are language specific (e.g. Python, Julia or R).
- A Session: links a specific notebook to a specific kernel instance.
Analogy: A restaurant manager (server) takes orders from waiters (notebook), delegates to the chefs (kernels) that read orders from an order ticket (session) and ensures the food gets back to the customer.
In Colab on the web, that simple runtime is actually a connection from your browser, to a single kernel session. In VS Code, you have the power to connect to exactly what you want.
Okay being on the bleeding edge and using some features which may be a bit rough around the edges? Read on!
Experimental features can be enabled in settings. After toggling, you may need to reload VS Code for it to take effect.
Please search for existing issues before filing a new one, especially for experimental features.
With the experimental Uploading feature enabled, once you've created a Colab server you can right click files and folders (or multi-selections of them) then select Upload to Colab.
If you only have one server assigned, your upload will begin immediately. If you have multiple servers, select the server you'd like to upload to.
The notification should communicate the outcome, but you can always manually peruse the Colab server's filesystem (e.g. !ls /content).
File.upload.demo.webm
With the experimental Server Mounting feature enabled, once you've created a Colab server you can mount it through:
- The command palette:
[Ctrl|Cmd]+Shift+P > Colab: Mount Server To Workspace.... - The notebook toolbar (Colab button in notebooks) > Mount Server To Workspace.
With the server mounted, you can view, create, edit, and delete files right in VS Code. Currently, file modifications outside of VS Code aren't picked up but can be by hitting the refresh icon at the top of the Workspace toolbar.
mount.demo.webm
With the experimental Activity Bar feature enabled, a Colab activity bar will show up in the left panel, and you can view Colab servers and interact with their /content directories right in VS Code.
Similar to Server Mounting, file modifications outside of VS Code aren't picked up. The workaround is to reload the VS Code window.
Activity.bar.setting.webm
With the experimental Terminal feature enabled, you may now open a terminal connected to your Colab runtime in 2 ways:
- Open the command palette (
[Ctrl|Cmd]+Shift+P) and invoke theColab: Open Terminalcommand. - Click the Colab button at the top of the notebook and select Open Terminal.