Enabling Auto Completion in AI Platform Notebook

Chie Hayashida
Google Cloud - Community
4 min readApr 6, 2020

AI Platform Notebook is a managed ML service which provides a JupyterLab environment. Machine Learning Engineers can create instances and start ML experiments quickly. It also allows them to integrate their experiment environment with other data management platforms such as BigQuery, dataproc, data flow, GCS, and so on.

But JupyterLab doesn’t support auto complete which was supported by Jupyter Notebook originally.

In this blog, we will introduce two options to enable auto completion at AI Platform.

Options to Enable Auto Completion

Auto Completion is a feature to give developers word suggestions when they type something in an editor without pressing a Tab key, for example. With Jupyter Notebook, we can use an unofficial extension called Hinterland through nbextensions to enable auto completion. AI Platform Notebook comes with JupyterLab, which is a successor to Jupyter Notebook, but it doesn’t have the Hinterland as its extension module. Although there is a long lived GitHub issue discussing this, it seems there are three options available at this moment.

Use language server with JupyterLab

You could install the JupyterLab LSP extension to your Notebook instance to enable auto completion in notebooks. Note that JupyterLab LSP extension is open source and not a Google product.

Here is the instruction to install the extension.

1. Create a new Notebook instance in AI Platform

a. From the left tab, select AI Platform > Notebooks > NEW INSTANCE > Python

b. Click CREATE

2. SSH to the Notebook instance

a. Click the instance name

b. Click SSH

c. Then click CONNECT

3. Install jupyter-lsp extension and python-language-server

a. Type the following commands in the SSH terminal

$ sudo pip install — pre jupyter-lsp

$ sudo jupyter labextension install @krassowski/jupyterlab-lsp

$ sudo pip install python-language-server[all]

b. Click RESET to reset the Notebook instance

4. Confirm if Auto Completion works

a. From the left tab, select AI Platform > Notebooks

b. Click OPEN JUPYTERLAB

c. Now you can use auto completion. Enjoy!

Use Jupyter Notebook

If you don’t have any specific reason to use JupyterLab, you could use Jupyter Notebook with the steps shown below.

1. Click “OPEN JUPYTERLAB” on Notebooks tab in AI Platform

2. Launch Classic Notebook

3. Work on Jupyter Notebook

Now you can use Jupyter Notebook and it has an auto completion feature. Enjoy!

Conclusion

In this blog post, we introduced how to use auto completion with AI Platform Notebooks. There are 2 options to use auto complete in Notebook instances. The first is to install the JupyterLab LSP extension and the second is to use Jupyter Notebook.

Enjoy a good JupyterLab life with AI Platform Notebooks!

--

--