Skip to content

Commit

Permalink
Issue 1424 - Latest flask-compress (1.6.0) breaks Dash (#1426)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc-Andre-Rivet authored Oct 6, 2020
1 parent a94fdc7 commit 63bb42f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
All notable changes to `dash` will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/).

## Unreleased
### Fixed
- [#1426](https://github.com/plotly/dash/pull/1426) Fix a regression caused by `flask-compress==1.6.0` causing performance degradation on server requests

## [1.16.2] - 2020-09-25
### Fixed
- [#1415](https://github.com/plotly/dash/pull/1415) Fix a regression with some layouts callbacks involving dcc.Tabs, not yet loaded dash_table.DataTable and dcc.Graph to not be called
Expand Down
13 changes: 13 additions & 0 deletions dash/dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import flask
from flask_compress import Compress
from werkzeug.debug.tbtools import get_current_traceback
from pkg_resources import get_distribution, parse_version

import plotly
import dash_renderer
Expand Down Expand Up @@ -49,6 +50,8 @@
from . import _validate
from . import _watch

_flask_compress_version = parse_version(get_distribution("flask-compress").version)

# Add explicit mapping for map files
mimetypes.add_type("application/json", ".map", True)

Expand Down Expand Up @@ -283,6 +286,16 @@ def __init__(
else:
raise ValueError("server must be a Flask app or a boolean")

if (
self.server is not None
and not hasattr(self.server.config, "COMPRESS_ALGORITHM")
and _flask_compress_version >= parse_version("1.6.0")
):
# flask-compress==1.6.0 changed default to ['br', 'gzip']
# and non-overridable default compression with Brotli is
# causing performance issues
self.server.config["COMPRESS_ALGORITHM"] = ["gzip"]

base_prefix, routes_prefix, requests_prefix = pathname_configs(
url_base_pathname, routes_pathname_prefix, requests_pathname_prefix
)
Expand Down
2 changes: 1 addition & 1 deletion requires-install.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Flask>=1.0.2
flask-compress==1.5.0
flask-compress
plotly
dash_renderer==1.8.2
dash-core-components==1.12.1
Expand Down

0 comments on commit 63bb42f

Please sign in to comment.