How to enable Autocompletion in Jupyter Notebook application

Wasin Waeosri
Developer Advocate Developer Advocate

Overview

With the rise of Data Scientists, Financial coders, Casual Developers, or Traders (aka Citizen Developers), and the rapid growth of Jupyter application, Jupyter Notebook and its next-generation, JupyterLab is a de-facto tool of those Citizen Developers. Thanks to IPython kernel, Notebook provides a powerful interactive shell, interactive data visualization, embedded documentation, and supports various programming languages such as Python (native supported), RJulia, and much more.

The Notebook application is easier to use when comparing to other traditional IDEs (Integrated development environment) or Editors. Citizen Developers do not need much programming language or technology experience to use the Notebook application. However, The Jupyter Notebook also provides Coding and Magic features which make Notebook a friendly development environment for both Citizen and Professional Developers.

This article demonstrates how to enable Python/Jupyter application coding autocompletion feature. The demo application uses content from the Refinitiv Data Platform (RDP) as an example library.

Introduction to Refinitiv Data Platform (RDP) Libraries

Refinitiv provides a wide range of contents and data which require multiple technologies, delivery mechanisms, data formats, and the multiple APIs to access each content. The RDP Libraries are a suite of ease-of-use interfaces providing unified access to streaming and non-streaming data services offered within the Refinitiv Data Platform (RDP). The Libraries simplified how to access data to various delivery modes such as Request-Response, Streaming, Bulk File, and Queues via a single library.

Depending on the level of service and data requirements, developers can easily choose how to access data services using the appropriate access channel defined within the library.

Using the library developers can access content from all 3 of the access points - all from within the same application if required. The RDP Libraries are available in the following programming languages:

  • Refinitiv Supported Editions: Python and TypeScript/JavaScript (coming soon)
  • Community-based Edition: C#

For more deep detail regarding the RDP Libraries, please refer to the following articles and tutorials:

Disclaimer

As this notebook is based on alpha version 1.0.0a7.post7 of the Python library, the method signatures, data formats, etc. are subject to change.

Python built-in help

You can install RDP Libraries - Python and JupyterLab in your environment with the following basic pip command:

    	
            $>pip install refinitiv-dataplatform==1.0.0a7.post7 jupyterlab
        
        
    

The above command will install the RDP Libraries - Python and JupyterLab in your environment (please see a step-by-step guide here). Then the Notebook application is ready for you. You can use the Python built-in help() function to display documentation of modules, functions, classes, objects, etc with the following syntax:

    	
            help([object])
        
        
    

However, the result is not always easy to read as the following examples:

Or

For the library that keeps involving like RDP Libraries, this is inconvenient even the RDP Library itself is easy to use.

IPython Autocompletion

Fortunately, the JupyterLab and Jupyter Notebook comes with the IPython magic command %config Completer.use_jedi = False that enables the library/function autocompletion (like IntelliSense in Microsoft development environment term).

You need to set the magic command %config Completer.use_jedi = False at the top cell of the Notebook application (like this Notebook).

Once you have enabled and run the %config Completer.use_jedi = False magic command, you can trigger the code autocompletion by pressing the tab button after the "." character.

This IPython command also enables the "shift + tab" buttons to show the function help and tooltip information.

You can also use "?" at the end of the function (without ()) to display documentation for objects and methods in IPython environment.

These autocompletion shortcuts also support the library properties/attributes as well.

Please note that all IPython helpers and autocompletion magic support all Python libraries in the Notebook environment, not limit to only RDP Libraries.

Refinitiv Workspace CodeBook

If you are Refinitiv Workspace or Eikon user, you can access CodeBook, the cloud-hosted Jupyter Notebook development environment for Python scripting from the application. The CodeBook is natively available in Refinitiv Workspace and Eikon as an app (no installation required!!), providing access to Refinitiv APIs that are already pre-installed on the cloud.

One benefit of using the CodeBook app is the environment has already enabled Jupyter Notebook magics for you. You can use all code autocompletion shortcuts (tabshift + tab, and ?) without setting any IPython Magic in your Notebook.

Please see more detail regarding the CodeBook app in this Use Eikon Data API or RDP Library in Python in CodeBook on Web Browser article.

Prerequisite

This demo project requires the following dependencies software.

  1. RDP Access credentials.
  2. Refinitiv Data Platform Library for Python.
  3. Python Anaconda or MiniConda distribution/package manager.
  4. Jupyter Notebook or JupyterLab.
  5. Internet connection.

Please contact your Refinitiv's representative to help you to access Refinitiv Data Platform credentials. You can generate/manage the AppKey from the AppKeyGenerator website or AppKey Generator tool in Eikon Desktop/Refinitiv Workspace application.

How to run the example

Please unzip or download the example application from GitHub into a directory of your choosing, and then follow the step-by-step instruction in Running the example Notebook of the project README.md file.

Conclusion and Next Step

Some Professional Developers may think Jupyter Notebook (and JupyterLab) is just a learning tool for Casual Developers like Data Scientists. However, the tool provides enough coding/development features for a wide range of Developers. The IPython Code Autocompletion feature (and other Magics) helps developers implement the code logic and navigate through the libraries/APIs in the same experience as the traditional IDEs.

There is some new development project that tries to merge the benefits/features of the traditional IDEs and Jupyter Notebook like Netflix's Polynote. While the JupyterLab also keeps evolving to make a better development environment and easier to use.

At the same time, the Refinitiv Data Platform (RDP) Libraries let developers rapidly access Refinitiv Platform content with a few lines of code that easy to understand and maintain. Developers can focus on implement the business logic or analysis data without worry about the connection, authentication detail with the Refinitiv Platforms.

References

You can find more details regarding the Refinitiv Data Platform Libraries and Jupyter Notebook from the following resources:

For any questions related to this article or Refinitiv Data Platform Libraries, please use the Developers Community Q&A Forum.