Skip to content

Commit

Permalink
Support Plotly Dash 0.32.1 (without hot reload)
Browse files Browse the repository at this point in the history
  • Loading branch information
pikhovkin committed Dec 7, 2018
1 parent 5d27478 commit a3ad3b8
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 10 deletions.
17 changes: 12 additions & 5 deletions dash/dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ def __init__(self, data, encoder=plotly.utils.PlotlyJSONEncoder, safe=False,
_re_index_scripts_id = re.compile(r'src=".*dash[-_]renderer.*"')


# pylint: disable=too-many-instance-attributes, too-many-arguments, too-many-locals
# pylint: disable=too-many-instance-attributes
# pylint: disable=too-many-arguments, too-many-locals
class Dash(object):
# pylint: disable=unused-argument
def __init__(self, url_base_pathname='/',
Expand Down Expand Up @@ -249,11 +250,17 @@ def _relative_url_path(path_prefix, relative_package_path='', namespace=''):

srcs = []
for resource in resources:
is_dynamic_resource = resource.get('dynamic', False)

if 'relative_package_path' in resource:
if isinstance(resource['relative_package_path'], str):
srcs.append(_relative_url_path(path_prefix, **resource))
else:
for rel_path in resource['relative_package_path']:
paths = resource['relative_package_path']
paths = [paths] if isinstance(paths, str) else paths

for rel_path in paths:
self.registered_paths[resource['namespace']]\
.add(rel_path)

if not is_dynamic_resource:
srcs.append(_relative_url_path(
path_prefix,
relative_package_path=rel_path,
Expand Down
2 changes: 2 additions & 0 deletions dash/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def _filter_resources(self, all_resources, dev_bundles=False):
filtered_resources = []
for s in all_resources:
filtered_resource = {}
if 'dynamic' in s:
filtered_resource['dynamic'] = s['dynamic']
if 'namespace' in s:
filtered_resource['namespace'] = s['namespace']
if 'external_url' in s and not self.config.serve_locally:
Expand Down
3 changes: 2 additions & 1 deletion dash/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ def _dash_component_suites(self, request, *args, **kwargs): # pylint: disable=u
ext = kwargs.get('path_in_package_dist', '').split('.')[-1]
mimetype = {
'js': 'application/JavaScript',
'css': 'text/css'
'css': 'text/css',
'map': 'application/json',
}[ext]

response = HttpResponse(self.dash.serve_component_suites(*args, **kwargs), content_type=mimetype)
Expand Down
2 changes: 1 addition & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;dash_core_components==0.35.1
;dash_core_components>=0.40.2
;dash_html_components>=0.14.0rc4
;dash_renderer>=0.14.1
;Django>=1.9,<2.2
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;dash_core_components==0.35.1
;dash_core_components>=0.40.2
;dash_html_components>=0.14.0rc4
plotly>=2.0.8
dash-renderer>=0.14.1
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ passenv = *

[py__]
commands =
pip install "dash_core_components==0.35.1" --no-deps
pip install "dash_core_components>=0.40.2" --no-deps
pip install "dash_html_components>=0.14.0rc4" --no-deps
python --version
python -m unittest tests.development.test_base_component
Expand All @@ -34,7 +34,7 @@ commands =
[py__dj]
changedir=tests/django_project
commands =
pip install "dash_core_components==0.35.1" --no-deps
pip install "dash_core_components>=0.40.2" --no-deps
pip install "dash_html_components>=0.14.0rc4" --no-deps
python --version
python manage.py collectstatic --noinput
Expand Down

0 comments on commit a3ad3b8

Please sign in to comment.