Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: VS Code button in Colab to directly open local VS Code instance into a pre-configured folder #116

Open
pranavAbe opened this issue Feb 5, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@pranavAbe
Copy link

pranavAbe commented Feb 5, 2022

Source Problem:

When I'm working with Colab, I store my project files on Google Drive under a particular folder. After initiating a Colab SSH connection and opening it from VS Code, I have to manually navigate through from the root folder on the Colab VM, all the way into my mounted Google Drive folder where my project files are stored to open them on VS Code and work with the files.

Feature Request:

I hope it'll be possible to specify a folder location (present on the VM) from the Colab Notebook, such that upon launching the SSH connection, I get a VS Code button (Similar to the GitHub VS Code button) to click and automatically open a VS Code instance on my local machine, opened to the previously specified folder on Colab.

Describe Alternatives You've Considered:

I have tried using the SSH Config command called RemoteCommand, to try and cd into the folder I want while I'm connected to the Colab VM through VS Code, but this doesn't work, to begin with, and even if it did, it only changes the directory on the terminal and not the folder into which VS Code is opened.

Additional Context:

For example, I'm looking to specify something like launch_ssh_cloudflared(password=password, open_folder_path='/content/drive/MyDrive/Colab Notebooks/') on the Colab Notebook while launching a SSH Tunnel, while it outputs a button like such upon execution:

Desired Output

Upon clicking this button, I expect it to open VS Code instance on my local machine into the specified Colab Notebooks folder (in this example), like this:

image

@pranavAbe pranavAbe added the enhancement New feature or request label Feb 5, 2022
@pranavAbe
Copy link
Author

So, I've done some digging into this on my own, and as much as I would like to make a Pull Request, I'm not entirely sure how to test and make sure there isn't any missing logic that might break functionality. I'll leave my findings here so you can build them into the project if you're interested, but if you would rather that I try and make a Pull Request, I'll try my best to work on it and build this functionality into the project.

So there will be two new parameters that launch_ssh_cloudflared will take, namely, starting_directory="/content", and vscode_build=stable. The possible inputs for starting_directory is an absolute path on the Colab VM's filesystem (with the default being /content, which is the default starting directory for a Colab Notebook VM), and the possible inputs for vscode_build will be stable (by default), or insiders.

Inside the launch_ssh_cloudflared function, you can check for the starting_directory parameter, and generate an IPython Display cell (just like is being done for the Git Repositories when using the init_git_cloudflared function) with the generated link logic for the button being:

if vscode_build == 'stable': 
    link=f"vscode://vscode-remote/ssh-remote+root@{ssh_domain}:{ssh_port}{starting_directory}"
elif vscode_build == 'insiders': 
    link=f"vscode-insiders://vscode-remote/ssh-remote+root@{ssh_domain}:{ssh_port}{starting_directory}"
else: 
    print("Invalid vscode_build argument obtained!")

(Note: The difference in the handler URI for users with the Stable VS Code build and the Insiders VS Code build, might be something you want to consider handling even for the init_git_cloudflared function too)

I hope you would consider writing this functionality into the project, as I believe that some users, including myself, who work on specific directories (mounted Google Drive locations) in Colab will find this feature useful to automatically open into, every time. Greatly appreciate the work you've done with Colab SSH so far. It's by far, such a game changer in the way I use Google Colab for my work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant