Dash 2.0 Migration

Dash 2.0 introduces several new features, including Long Callbacks, Flexible Callback Signatures, and a simpler import statement.

Some updates to Dash change how existing features work, and you will need to update your apps for them to continue to function correctly.

Below is an outline of what updates you’ll need to make to your apps, along with a short overview of new functionality you’ll find in Dash 2.0.

Breaking Changes — Callbacks

If you are currently naming arguments to @app.callback with state=, you need to either also use input for the input arguments, or remove state.

Breaking Changes — Python 2 Support

As of version 2.0, Dash no longer supports Python 2.

Dash 2.0 includes a simpler way to import Dash as well as its dependencies and components.

If you update your apps to use Dash 2.0, we recommend you use this simpler import statement and replace references to dash_html_components, dash_core_components, and dash_table in your app imports.

Dash 1.x

import dash_html_components as html
import dash_core_components as dcc
import dash_table

Dash 2.0

from dash import Dash, callback, html, dcc, dash_table, Input, Output, State, MATCH, ALL

In the above example, html, dcc, and dash_table are imported along with Dash, callback, Input, Output, State, MATCH, and ALL.

Installs

The changes that allow simpler import of dash_html_components, dash_core_components, and dash_table also impact installs of these components. If you have these referenced in any requirements.txt files, you should update them.

New Features to Improve your Apps

As you update your apps, you may also want to consider trying out some of Dash 2.0’s new features.

Long Callbacks

If you are currently using Dash 1.x and experiencing server timeouts with callbacks that run for a long time, you can use long callbacks to solve this issue. Long callbacks run callback logic in a separate process, meaning the app is still available while the callback runs. See the Long Callbacks chapter for more details.

Flexible Callback Signatures

In Dash 1.x callback arguments are positional, meaning arguments are passed to the callback function in the same order as they are in the callback decorator. Flexible callbacks
allow for either positional or keyword arguments. See the Flexible Callback Signatures chapter for more details.

@dash.callback

The decorator @dash.callback is an alternative to using @app.callback in your apps. It is useful when building reusable components using pattern-matching callbacks and All-in-One components. To import and use it:

import dash

@dash.callback(...)

Similarly, dash.clientside_callback can be used as an alternative to @app.clientside_callback:

import dash

dash.clientside_callback(...)

Both can also be imported by importing from dash like this:

from dash import clientside_callback, callback

And then used like this:

@callback(...)
clientside_callback(...)

Limitations

orjson Support

Dash 2.0 adds opt-in support for orjson. If the orjson library is installed, Dash will use it to serialize data to JSON, improving callback performance. See “Data Serialization” in the Performance chapter for more information.