Announcing Bokeh 2.0

Bokeh
Bokeh
Mar 9 · 7 min read

Bokeh 2.0 brings enhanced security options, new widgets, improved Jupyter integration, and more!

This is a major release that includes some breaking changes, with the goal of improving the usability and maintainability of the library. The most important change to be aware of is that Python 3.6 is now the minimum Python version. Python 2 is no longer supported. For details about other changes, see the full release notes. If you have questions after upgrading, we encourage you to stop by the Bokeh Discourse! Friendly project maintainers and a community of Bokeh users are there to help you navigate any issues that arise.

If you are using Anaconda, Bokeh can most easily be installed by executing conda install -c bokeh bokeh. Otherwise, use pip install bokeh.

What’s New

Bokeh 2.0 includes a number of improvements, fixes, and features:

  • Security. Improvements related to CDN loads, session tokens, and other session metadata.
  • New and Improved Widgets. A new MultiChoice widget and a complete rework of the existingDatePicker.
  • Jupyter Integration. Integrate ipywidgets into Bokeh applications or the converse — include Bokeh content in to ipwidgets layouts in the notebook.
  • Behind the Scenes. New GitHub Workflows, code formatting standards, code quality monitoring, and adoption of Python 3 features.
  • The Rest. New geographic tile providers, new import capabilities for directory-style apps, and an assortment of bug fixes.

Security

Starting with version 2.0, when Bokeh loads BokehJS JavaScript resources from cdn.bokeh.org it will construct script tags with Sub-resource Integrity (SRI) hashes by default:

<script type="text/javascript"        
src="https://cdn.bokeh.org/bokeh/release/bokeh-2.0.0.min.js"
integrity="sha384-5Y+xuM....Z7C2N" crossorigin="anonymous"></script>

Browsers will compare downloaded scripts to the published hashes to ensure the scripts are authentic.#9480

This version brings several changes to the way websocket connections are authorized. #3458 #9505 Rather than a simple (optional) signed session id, Bokeh now uses a JWT token with several improvements:

  • No longer passed in HTTP request arguments (which might end up in logs)
  • Can be set to expire after a specified time (default: 5 minutes)
  • Include additional properties including cookies and request headers, as well as user-specified metadata

It is still possible to generate and use a signed session ID (it is now part of the token).

These features build upon the auth hooks added in version 1.4 and allow for more customization of authentication and authorization workflows with Bokeh apps.

New Widgets and Widget Improvements

A new, lighter-weight MultiChoice widget has been added, based on the choices.js library. This widget offers the same functionality as multi-select, but with a cleaner, minimal style that takes up much less vertical space. #9546

The DatePicker widget has been re-impemented from the ground up, and is now based on the Flatpickr library. This change has several positive impacts:

  • Resolves persistent timezone bugs by expressing dates as unambiguous ISO date strings instead of timestamps
  • Adds new options for specifying valid/invalid dates and date ranges
  • Allows the calendar to be hovered above, below, or displayed inline

All the changes are behind the scenes — no changes have been made to the API. #9509

Formatting options to handle scientific notation have been added in two places:

  • RangeSlider can now be configured with a TickFormatter for formatting its appearance#9469
  • New cell formatter ScientificFormatter can be added to DataTable columns.#9304

Jupyter Integration

Thanks to recent work by core contributors Philipp Rudiger and Mateusz Paprocki, it is now possible to use ipywidgets in Bokeh applications. This includes sophisticated widgets such as ipyleaflet and ipyvolume.

Note that at this time, this is designed to work on the server rather than the notebook; documentation and example code snippets can be found here.

Behind the Scenes

Version 2.0 also brings several internal changes that will mostly be of interest to our contributor and developer community.

CI moved to GitHub Workflows — testing continuously on Linux, MacOS, and Windows for the first time. LGTM checks have been added to perform static analysis that proactively looks for bugs or vulnerabilities.

Code formatting continues to be improved, with isort import formatting enforced on the entire codebase. Type annotations are being added incrementally across the codebase. We are also considering automatically applying Black formatting in the near future.

Finally, all Python 2 codepaths have been removed, which means newer Python features like f-strings and native coroutines can finally be used throughout.

And the Rest

New data tile providers have for OpenStreetMap and ESRI Imagery were suggested and then added by contributor comperem. #9560 Thanks, comperem!

Bokeh 2.0 includes several miscellaneous fixes and features:

  • Network graphs can now accept arbitrary markers for nodes #9572
  • DateRangeSlider not recognizing date.today() as a value#9702
  • HoverTool resizing and text-wrapping bugs #9717, #2673
  • Better behavior for very small Spinner steps #9672

The move to support only Python 3 has enabled us to allow package-relative imports in directory-style apps. For example, an import statement such as

from .data import process_data

now works as expected in the main.py of a directory-style Bokeh server app. #9545

For the detail-oriented, you can browse the full list of issues in the 2.0 milestone.

The Future

As excited as we are about this Bokeh 2.0 release, we are equally excited about improvements yet to come.

Develop BokehJS as a first-class JavaScript library

For a long time, BokehJS was more or less a hidden implementation detail of Bokeh. But more people are expressing interest in using BokehJS directly in their web applications. There is a lot of work to do: better docs and examples are needed, and BokehJS needs changes to be more easily integrated with in popular and standard web frameworks. This is a great opportunity for JavaScript developers to get involved with Bokeh development!

Built-in LaTex / MathText support

A long-time ask, especially from scientific and academic quarters. We would like to integrate MathJax as an optional dependency in order to afford math text in labels, axis ticks, and plot titles.

Support Bokeh protocol usage on its own

The “reference” Bokeh server built on Tornado is great for making interactive visualizations backed by PyData tools. But for many users, having to run a separate server from their Django or Flask app is a burden. We would like to make it so the Bokeh protocol can be leveraged on its own for powerful Python⟷JS eventing and synchronization. Many users have expressed interest in this and some preliminary work has already been done around Django channels.

Support for virtual widgets

It’s wonderful that Bokeh is extensible through custom extensions, but writing a custom extension is still a high bar to clear. We would like to provide stable, minimal, data-only interfaces for common widgets, so that hooking up your own custom web components (that you can style and lay out on the page yourself, however you like) becomes a snap.


These and other big-picture ideas can be found on our Project Roadmap as well as our GSOC 2020 Ideas Page.

Next Steps

Before we wrap up, we’d like to make a special mention of new contributor RyanRio, who made the js_link feature considerably more useful by submitting a Pull Request to add attribute indexing. This is a great example of a Bokeh user who identified an area for improvement, submitted an issue, and then worked out a solution that improves things for everyone — thanks, RyanRio!

If you’d like to become a Bokeh contributor, but don’t have a specific change in mind, a great place to start is to look over the good first issue label on the issue tracker.

For support questions, check out the Bokeh Discourse! You can search for similar topics, or post examples of your issue or question and get answers from the community.

To get involved with developing the Bokeh library itself, you can stop by Bokeh’s Zulip chat channels for guidance on best practices and technical considerations.

bokeh

Bokeh is a powerful, interactive data visualization library for modern web browsers.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store