GibbsConsulting / jupyter-plotly-dash

Jupyter notebook wrapper for plotly dash applications
GNU Affero General Public License v3.0
81 stars 12 forks source link

Sharing data between callbacks error #31

Open vinaykumar80 opened 5 years ago

vinaykumar80 commented 5 years ago

Hi,

I am trying to execute the example code given in Dash user guide and documentation explaining Caching and Signaling concept of Sharing data between callbacks - https://dash.plot.ly/sharing-data-between-callbacks , when I try to integrate this code in JupyterDash and run in notebook cell it gives me the following error:

AttributeError Traceback (most recent call last)

in 18 #app = dash.Dash(__name__, external_stylesheets=external_stylesheets) 19 app=JupyterDash('Caching and Signaling') ---> 20 cache = Cache(app.server, config={ 21 'CACHE_TYPE': 'redis', 22 # Note that filesystem cache doesn't work on systems with ephemeral **AttributeError: 'JupyterDash' object has no attribute 'server'** Am I doing something wrong here or how can we get this example working in Jupyter-plotly-dash? Complete code file (.py) is attached in the zip file Thanks! - [ ] [Caching_Signaling_jupyter-plotly-dash.zip](https://github.com/GibbsConsulting/jupyter-plotly-dash/files/2869485/Caching_Signaling_jupyter-plotly-dash.zip)
vinaykumar80 commented 5 years ago

@GibbsConsulting : Did you get a chance to look into above question? Please let me know if you need additional information.

Thanks!

GibbsConsulting commented 5 years ago

If you are going to remain within a Jupyter notebook, then you can use the notebook environment to store state. This would avoid the need to use an external cache or similar, but at the same time would require code changes to not use the cache.

Going forward, we could add a cache variant to make this relatively transparent. See GibbsConsulting/django-plotly-dash#120

vinaykumar80 commented 5 years ago

Ok, are you aware of any example code to store the state within notebook? If yes, it will help me integrating it into dash apps within notebooks.

Regarding the cache variant implementation in jupyter-plotly-dash, is there any tentative timeline as to when this feature could be completed?

Thanks!

delsim commented 5 years ago

Just reference a local (to the notebook) variable in a callback. The value used will be that of the time the callback is invoked. Note that changing the value of the variable will not automatically propagate to the Dash app until a callback is invoked.