Black Lives Matter. Please consider donating to Black Girls Code today.

Show and Tell - Dash on Wheels

Hi everyone,

I really like data visualisation and I’m flashed by Dash a lot. The callback functions / “crossfilter” is really the killer feature for me. I used dc.js / crossfilter before … but now in python, with pandas. Great.

Just wanted to announce that I integrated Dash in the PythonOnWheels web framework.
You may say: oh know, not yet another framework.
But the idea is to make you focus on the data, logic and visualisation and not so much the framework. It shall take away the boring, boilerplate and app infrastructure stuff. Rails workflow.

I made a short online demo integrating dash in a bootstrap4 view, served from a NoSQL DB (tinyDB, which is also great by the way :wink: The demo is the callback example from the dash user guide. (Gapminder… also great)

check it here if you like:
https://www.pythononwheels.org/dash

Oh, and not to forget. The implementation is based on the great idea of Ead from this dash community forum.(Wish I had more hands to give you more thumbs up!)

Any feedback appreciated.

Klaas

4 Likes

Hi Klaas, thanks for sharing this. I want to use POW for a work project but I never can get the demo server.py to run. I verified I created the dashtest directory, virtual environment, $PYTHONPATH, and pip install -r requirements.txt correctly. What am I doing wrong?

(dashtest) ~/D/dashtest ❯❯❯ python server.py

Traceback (most recent call last):
File “server.py”, line 16, in
from dashtest.application import Application, log_handler
File “application.py”, line 12, in
from dashtest.database.sqldblib import Base, Session, engine
File “database/sqldblib.py”, line 67, in
from dashtest.models.sql.sqlmodel import SqlModel
File “models/sql/sqlmodel.py”, line 1, in
from dashtest.models.sql.basemodel import SqlBaseModel
File “models/sql/basemodel.py”, line 18, in
from testapp.config import database as dbcfg
ModuleNotFoundError: No module named ‘testapp’

Hi Philip,

this is not your fault. This is a bug in POW 9.10 refering to a non existing module.

Please update pythononwheels to 0.911

pip install -U pythononwheels

I tested the dash setup with this today and it worked fine.
It’s probably best to delete the dashapp dir and generate a new one with 0.911
just as you did before.

Sorry for the inconveniance and many thanks for pointing it out !

1 Like

Thanks, Klaas. The server and the dash demo now run perfectly! However, I get a 500 error if I attempt to access localhost:8080/dash after updating the dash packages to their current versions. Reverting to the old versions you specify in dash_requirements.txt restores the app again. Please try pip install -U dash, restart the server, and let me know if you have the same results.

Status: 500 Message: (<class 'NameError'>, NameError("name 'http_code' is not defined"), <traceback object at 0x112e3fd20>) URI: /dash

Seems to be an issue with the missing
csrf_protect option in the new(er) Dash() Class.

The parameter itself is missing. Probably due to: this issue

Need to check how to fix this …
Problem” is that without csrf set the app complains about cross site loaded javascripts for Dash…

I’ll try to update that … but need to break it down a bit.

Hey Philip,

Works now with Dash Versions:

dash==1.0.2
dash-core-components==1.0.0
dash-html-components==1.0.0
dash-renderer==1.0.0
dash-table==4.0.2

I will integrate the update in the next two days to a new PythonOnWheels release.
Will upload a working pre-release Version tonight (0.911b1). So you and anyone else can play around with PoW and the up-to-date Dash versions.
Just update with

pip install -U pythononwheels

Need to add some tests and fine tuning for a 0.912

Really great that you put me up to this road.

Klaas

Wonderful news, Klaas! So glad to hear you are updating POW to work with the latest versions of dash. I am one of those trouble-makers who updates packages and breaks everything lol. (p.s. should I avoid updating tornado?)

:wink:

wasn’t there a famous commercial saying the “troublemakers” are the ones that actually change the world ??

But seriously … updating tornado as well is a good idea. Updates in Tornado include a lot of improvements in asyncIO and type annotations. Really worth it. I tried it and it only needed some tiny fixes to get it working with

tornado==6.0.3

I will now try to make a package including the dash and tornado updates. I think that will really improve the PoW options a lot.
May take another day or two since I also tackle some other areas like updating the 404 and error template, which I saw a lot in the last days :wink:

best regards,
klaas

Perfect! I’ll wait patiently :slightly_smiling_face:

My developer is using websockets for our most active dashboards so she’ll be happy to hear about your updates to POW.

I think I’m done.
Can you please update PythonOnWheels to ( 0.912 ) and verify ?

pip install -U pythononwheels

Should work with:

dash==1.0.2
dash-core-components==1.0.0
dash-html-components==1.0.0
dash-renderer==1.0.0
dash-table==4.0.2

and:

tornado==6.0.3

… feedback appreciated :wink:

Verified! The demo server and dash app both loaded perfectly, Klaas. Thank you for all you have done. I’ll install this new version in our dev repo tomorrow and start migrating our current dashboards over.

Because I can’t stop myself, I updated all other outdated packages to their current versions with no negative repercussions (yet). If I messed up anything, I can always revert to the versions in your requirements file. :slight_smile:

Hey, Philip, great to hear. Being up-to-dat with the modules is really great for PoW. If anything else pops up just create an issue or post here for Dash relatd things.

Short update.
PythonOnWheels 0.914 now supports Dash 1.2.0

Dash 1.2.0 works now with pythononwheels! (Sept 2019)

More specific:
dash==1.2.0
dash-core-components==1.1.2
dash-html-components==1.0.1
dash-renderer==1.0.1
dash-table==4.2.0

Just
pip install -U pythononwheels

Short tutorial here:
https://www.pythononwheels.org/dash

Hey everyone,

just another short update info.
PythonOnWheels 0.916 now supports Dash 1.6.0 (Nov 2019)

More specific:

dash==1.6.0     
dash-core-components==1.5.0     
dash-daq==0.2.1     
dash-html-components==1.0.1     
dash-renderer==1.2.0     
dash-table==4.5.0 

Just
pip install -U pythononwheels

Demo and short tutorial here:
https://www.pythononwheels.org/dash

If you encounter any problems just drop a line.
Btw: currently also implementing Redis support… might be handy to handly in memory data for dash…