Remote Collaboration on Python Projects with VSCode
Guest post by Robert Jordan and Noah Gift
Bios
Robert is a software architect with over 20 years designing, implementing, and deploying production applications for some of the worlds largest media and scientific customers. He is a founder at Pragmatic AI Labs: https://paiml.com/
Noah is a ML lecturer for UC Davis Graduate School of Management’s MSBA and Northwestern’s MSDS program. He is the author of Pragmatic AI: An Introduction to Cloud-Based Machine Learning and is a founder at Pragmatic AI Labs: https://paiml.com/
Introduction
In this article we’ll demonstrate how VSCode and its rich ecosystem of extensions can enable a productive distributed collaboration workflow. VSCode is one of the top choices for Python developers because it “just works” and has support for key features Python developers are used to: VIM bindings, pylint support, auto-completion and a rich extension ecosystem.
VSCode also works exceptional from the terminal when using virtual environments. If a virtual environment is sourced, and then “code.” is typed, VSCode will open a new session, that “does the right thing”, for a Python project.
Another common way to integration into Python projects is to use the integrated terminal to do Data Science with Pandas.
The dream scenario would be to be able to selectively work in this shared environment with collaborators. Up until now, this has not really been possible. In this article, we cover an exciting new workflow possibility.
The Tools
One of the best things about VS Code is its incredible ecosystem of extensions. True to form, the distributed collaboration space has a number of great extensions from Microsoft, third party vendors and the community. We’ll be focusing specifically on a few foundational extensions that work for pair programming on projects. While these extensions are the focus of the article, we definitely encourage you to explore the plugin ecosystem on your own.
Introducing VS Live Share
VS Live Share and VS Live Share Audio comprise the basis of a productive collaboration environment with VSCode. These extensions enable several key collaboration scenarios:
- Pair programming.
- Code review.
- Instructor led learning.
It is very common to need to fire up screen sharing software to work through some particular bug as team. Unfortunately, that workflow can be cumbersome. With VS Live Share, it helps you keep focused by allowing VSCode to work in a “pair programming mode”.
Installation
Like most VSCode extensions the VS Live extensions can be installed from within VSCode by searching in the Extensions panel from within VSCode. Tip: You can install VS Live Share, VS Live Share Audio, and Team Chat as a bundle by selecting VS Live Share Extension Pack. On Windows you may be asked to allow traffic through the local firewall. If you collaborate with developers on the same local network, you should allow this. If you don’t want to allow the traffic (or are prohibited by policy) the plugins will still work perfectly, however all traffic will route via the internet rather than across your LAN.
Start Sharing
Once the extensions are installed sharing a session and inviting collaborators is simple:
From the Live Share pane select “Start collaboration session…”
This will bring you to the Sign In page which will allow you to sign in with either a Microsoft or Github Account. Note: You no longer need an account to join a session as a guest.
Once logged in a unique URL is generated for the collaboration.
You can send this URL via Teams, Slack, Email, or any other means of communication. Anyone with the link will be able to join your session. There are obvious security precautions that should be taken before distributing the link… This link will allow anyone with access to it to read your source code (at a minimum). Use caution here.
Join a session
Joining a session is even easier that starting one. Simply Select ‘Join collaboration session’ from the VS Code Live Share panel and enter the URL provided by the session owner.
Collaborate!
Real time editing
Once in a collaboration you can observe others in real time as they move around and edit the project. The names of each participant will appear next to their cursor as they browse and modify code. If the session owner has given the participants write access they can even modify the project!
Voice
Collaboration isn’t very effective if there isn’t an easy stream of communication. Luckily, VS Code Live Audio is integrated right into your IDE! From the VS Live Code panel simply select ‘Start audio call…’ and an audio channel will be opened to all participants. This “one stop shop” collaboration also is very compelling, as it gets rid of a hassle of needing multiple forms of communication.
Shell
Any shells open in VS Code will also be shared (read only by default). This allows participants to see any commands as they execute along with the host. Additionally, the host can make a shell read/write by context menu in the VS Live Share pane. It should go without saying, but use caution with this feature. Any commands executed by a guest are executed on the hosts machine with the hosts account credentials.
Shared Servers
If you’re collaborating on a server project you may want to share the local development server with your collaboration partners without the complexity of firewall configurations and so forth. Luckily VS Code Live Share handles this seamlessly. To share a local server port simply select “Shared Servers” from the VS Code Live panel and enter the local port number
.
Now any of your collaborators can access the local server running on your machine at the same local URL on their machine.
Code review comments
VS Code Live Share has recently added the ability for collaborators to view the state of Version Control including diffs. Additionally, you can now leave code review comments in-line with the code.
Conclusion
The VS Code Live Share collection of extensions enable teams to easily and effectively collaborate across vast distance. The combination of real-time shared editing, voice and text chat with very low setup cost is an amazing addition to any developer’s toolbox. This project happened to be a Python Data Science project, but these features work with any language. If you’re a Python programmer who hasn’t tried VS Code yet, you owe it to give it a spin.
Resources
Connect 2018 Demo on VS Code and Live Sharing https://www.microsoft.com/en-us/connectevent#
Connect 2018 Announcements https://blogs.microsoft.com/blog/2018/12/04/empowering-every-developer-to-achieve-more-at-microsoft-connect-2018/
Microsoft Docs for Live Share within Visual Studio and VS Code https://docs.microsoft.com/en-us/visualstudio/liveshare/