JupyterLab 2.0. Let’s take a glimpse into the future of... | by Roman Orac | Towards Data Science

A few days ago, I wrote a story Are you still using JupyterLab? and I got an amazing response. Readers pointed me to various new IDEs that are being developed for Data Science, but one of them stood out.
Michal Krassowski left me a note about a project that he and other contributors have been working on. JupyterLab-LSP is a Language Server Protocol integration for JupyterLab. In short, it adds new superpowers to JupyterLab, like code navigation, hover suggestions, linters, autocomplete and rename. I am really excited about this one as it addresses most of the issues, where PyCharm is superior to JupyterLab.
Let’s take it for a test drive
Here are a few links that might interest you:
- Labeling and Data Engineering for Conversational AI and Analytics- Data Science for Business Leaders [Course]- Intro to Machine Learning with PyTorch [Course]- Become a Growth Product Manager [Course]- Deep Learning (Adaptive Computation and ML series) [Ebook]- Free skill tests for Data Scientists & Machine Learning Engineers
Some of the links above are affiliate links and if you go through them to make a purchase I’ll earn a commission. Keep in mind that I link courses because of their quality and not because of the commission I receive from your purchases.
After installing JupyterLab-LSP you will notice “Fully initialized” icon in the status bar. This means that JupyterLab-LSP is working.
Code linting works great. In the example below, It shows “imported by unused” warning.
This one is one of the most anticipated features for me. Let’s test it.
Code Completion (CC) didn’t work for pandas or numpy as can be seen in a video below. I also tried CC with columns in pandas DataFrame, but it wasn’t any different. CC did work great with system libraries and with classes I’ve defined.
Some pandas functions take many arguments, some of which I rarely use. Each time I use such function, I have to google for documentation to refresh my mind about it.
JupyterLab-LSP adds Function Signature Suggestions (FSS), which works great. You get a nice popup — not too intrusive, just right.
FSS could be further improved by highlighting the current argument that you are editing, like deoplete-jedi plugin in NeoVim.
Function Signature Suggestions works great, but there is a still room for improvement
JupyterLab-LSP has also a nice diagnostic panel that lists all the warning and error. This is really useful as red underlinings may be overlooked from time to time.
I was a bit disappointed with this one as I thought it will do refactoring, but it is a keyword replacement. I tried to refactor a variable name, but it also renamed a string as can be seen in a video below.
JupyterLab-LSP is packed with useful features, like Go to Definition — would you like to see how pandas DataFrame works behind the scenes — just use Go to Definition.
Code formatting will be a part of the LSP extension at some point too!
Would you like to see how pandas DataFrame works behind the scenes — just use Go to Definition
Make sure you have the latest JupyterLab installed — 2.1.0 at the time of writing. You also need to enable Extension Manager in JupyterLab.
pip install -U jupyterlab
Install LSP server extension:
pip install jupyter-lsp
Install node (command is for macOS):
brew install nodejs
Install frontend extension:
jupyter labextension install @krassowski/jupyterlab-lsp
Install LSP servers for programming languages:
pip install 'python-language-server[all]'
Start jupyterlab and you should see “Fully initialized” icon in the status bar.
By the positive comments, I’ve made, you might be thinking that I will be using JuypterLab 2.0 with LSP daily. You would be surprised to know that I’ve actually installed the older version right after I finished this story. Why is that?
While new features work great, other extensions that I use do not support JupyterLab 2.0 yet. Those are jupyterlab-vim for Vi keybindings and jupyterlab_code_formatter for code formating. These two extensions are at the moment more important to me than LSP support. Maybe we can have the best of both worlds as it seems that JupyterLab-LSP supports also JupyterLab 1.x, but I haven’t tried it yet.
# for JupyterLab 1.xjupyter labextension install @krassowski/jupyterlab-lsp@0.8.0
In short, JupyterLab-LSP is a huge improvement and I can say I am going to be using it for sure in the future
Follow me on Twitter, where I regularly tweet about Data Science and Machine Learning.