Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Incompatibility with Dash v2.1.0 #75

Closed
t89 opened this issue Jan 30, 2022 · 7 comments · Fixed by #76
Closed

Incompatibility with Dash v2.1.0 #75

t89 opened this issue Jan 30, 2022 · 7 comments · Fixed by #76

Comments

@t89
Copy link

t89 commented Jan 30, 2022

Quick-Fix on User-Level

If you are a user and looking for a quick fix do this:

$ python -m pip uninstall dash
$ python -m pip install 'dash==2.0.0'

Cause

I spent the past 30 minutes diving through the source code of both projects and I would assume it has to do with:
plotly/dash#1876

Problem

Running the following lines always leads to the AttributeError below:

from jupyter_dash import JupyterDash
app = JupyterDash(__name__)
app.run_server(mode='inline')
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Input In [12], in <module>
      1 from jupyter_dash import JupyterDash
      2 app = JupyterDash()
----> 3 app.run_server(mode='inline')

File ~\.pyenv\pyenv-win\versions\3.10.2\lib\site-packages\jupyter_dash\jupyter_app.py:231, in JupyterDash.run_server(self, mode, width, height, inline_exceptions, **kwargs)
    229 else:
    230     requests_pathname_prefix = '/'
--> 231 self.config.update({'requests_pathname_prefix': requests_pathname_prefix})
    233 # Compute server_url url
    234 if self.server_url is None:

File ~\.pyenv\pyenv-win\versions\3.10.2\lib\site-packages\dash\_utils.py:169, in AttributeDict.update(self, other)
    166 def update(self, other):
    167     # Overrides dict.update() to use __setitem__ above
    168     for k, v in other.items():
--> 169         self[k] = v

File ~\.pyenv\pyenv-win\versions\3.10.2\lib\site-packages\dash\_utils.py:158, in AttributeDict.__setitem__(self, key, val)
    156 def __setitem__(self, key, val):
    157     if key in self.__dict__.get("_read_only", {}):
--> 158         raise AttributeError(self._read_only[key], key)
    160     final_msg = self.__dict__.get("_final")
    161     if final_msg and key not in self:

AttributeError: ('Read-only: can only be set in the Dash constructor or during init_app()', 'requests_pathname_prefix')
@t89
Copy link
Author

t89 commented Jan 30, 2022

plotly/dash@bea2697

@t89 t89 mentioned this issue Jan 30, 2022
5 tasks
@jborman-exos
Copy link

jborman-exos commented Jan 31, 2022

I wrote the PR linked above - the issue seems to stem from how this package's JupyterDash is subclassing the original Dash app class, specifically this line here.

JupyterDash appears to be trying to modify the config.requests_pathname_prefix after its internal Flask server has been initialized. JupyterDash should either specify this kwarg during __init__() of the parent Dash class or utilize the delayed Flask server init pattern: .init_app(server=flask_server, requests_pathname_prefix=...).

I don't use this package nor am I familiar with its internals, someone familiar with this repo should make the change.

pieeri added a commit to noosenergy/dash-material-components that referenced this issue Feb 4, 2022
Current incompatibility with jupyter-dash & django-plotly-dash
plotly/jupyter-dash#75
GibbsConsulting/django-plotly-dash#354
@kennethleungty
Copy link

Facing the same problem here, looking forward to this getting resolved!

@rshih32
Copy link

rshih32 commented Feb 9, 2022

+1 on this

1 similar comment
@jonasvdd
Copy link

jonasvdd commented Feb 10, 2022

+1 on this

@alexcjohnson
Copy link
Collaborator

Ha, JupyterDash was exploiting a loophole in the way Dash locked the parts of its config that it deems risky to set late - @t89 you're correct that this is due to plotly/dash#1876 where we closed the .update loophole.

We're working on a fix for this - just need to figure out whether it's better to continue working around the lock here, or if the fact that this is safe for JupyterDash means it's safe for Dash.

In the meantime, add this before your app.run_server call and it'll work with Dash 2.1:

del app.config._read_only["requests_pathname_prefix"]

@alexcjohnson
Copy link
Collaborator

Fixed in v0.4.1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants