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.
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
MultiChoicewidget and a complete rework of the existing
- Jupyter Integration. Integrate
ipywidgetsinto Bokeh applications or the converse — include Bokeh content in to
ipwidgetslayouts 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.
cdn.bokeh.org it will construct script tags with Sub-resource Integrity (SRI) hashes by default:
Browsers will compare downloaded scripts to the published hashes to ensure the scripts are authentic.
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.
- 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.
Formatting options to handle scientific notation have been added in two places:
RangeSlidercan now be configured with a
TickFormatterfor formatting its appearance
- New cell formatter
ScientificFormattercan be added to
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
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
Bokeh 2.0 includes several miscellaneous fixes and features:
- Network graphs can now accept arbitrary markers for nodes
date.today()as a value
HoverToolresizing and text-wrapping bugs
- Better behavior for very small
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.
For the detail-oriented, you can browse the full list of issues in the 2.0 milestone.
As excited as we are about this Bokeh 2.0 release, we are equally excited about improvements yet to come.
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.
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.