Inside Dash - a plotly framework
Alex Pawlowski
knoxpy may 2018 meetup
@apawlows
KnoxPy
Python users group in Knoxville, TN Meetings are the first Thursday of the month 6:30 - 8:30pm @ Technology Cooperative
knoxpy.org
knoxdevs.com
meetup.com/knoxpy
knoxpytn
github.com/knoxpy
info@knoxpy.org
tinyletter.com/knoxpy
Shameless plugs
![](http://knoxdevs.com/kd_logo2.png)
KnoxDataSci
knoxdata.org
knoxdata
info@knoxdata.org
data science group in Knoxville, TN
data
Technology Cooperative
meets every third Thursday 6:30-8:00
-
You write code.
-
Maybe you're generating or displaying data.
-
How do you get others to interface with it?
![](https://imgs.xkcd.com/comics/algorithms.png)
![](https://imgs.xkcd.com/comics/making_progress.png)
True, a spreadsheet can give others away from code, access to data...
but the logic is locked away in the sheet...
Enter Dashboards...
- Obviously, dashboards aren't new.
![](https://s3.amazonaws.com/media-p.slid.es/uploads/305792/images/4870800/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/305792/images/4870828/pasted-from-clipboard.png)
The fundamentals really haven't changed
![](https://s3.amazonaws.com/media-p.slid.es/uploads/305792/images/4870834/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/305792/images/4870880/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/305792/images/4870896/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/305792/images/4870906/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/305792/images/4870913/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/305792/images/4870916/pasted-from-clipboard.png)
Why do something different?
- Reporting tools often are locked to vendors
- often fall behind users' expectations of what they get elsewhere
- code to create dashboard is different that remaining area of expertise
hey. I thought this was a python talk
- It is.
- plotly made something that allow you to just write python so you can be like the cool kids
![](https://s3.amazonaws.com/media-p.slid.es/uploads/305792/images/4870950/zombomeme28042018113824.jpg)
h/t @mock
didn't you give a talk in R or something
- I did.
- That package is called shiny
- It allows you do a lot of cool things
- I like R
- I like the community that builds packages
- But maybe the rest of your server logic doesn't use R to run...
- also plotly claims that dash is not a replica of Shiny. ¯\_(ツ)_/¯
- "Idioms and philosophies are different."
- I believe 'em
Dash. what is it?
History
+
+
+
+
![](https://blog.f1000.com/wp-content/uploads/2017/07/logo.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/305792/images/4871001/pasted-from-clipboard.png)
2017-06
![](https://s3.amazonaws.com/media-p.slid.es/uploads/305792/images/4871009/pasted-from-clipboard.png)
2017-08
2018-04
![](https://s3.amazonaws.com/media-p.slid.es/uploads/305792/images/4871031/pasted-from-clipboard.png)
2017-09
Editable and sortable tables
Today
You know about dash
Inside a Dash app
- 1 file for [your-app].py, import modules like normal py scripts
Core Components
- the cool stuff
- dropdowns, graphs, markdown, tabs, upload, etc.
import dash
import dash_core_components as dcc
import dash_html_components as html
app = dash.Dash()
app.layout = html.Div([
# Your code
])
if __name__ == '__main__':
app.run_server(debug=True)
HTML Components
- the needed stuff
- HTML tags, HTML attributes
What do good packages need?
- Support from a community
- Documentation
- Good License; Ability to Contribute
- Active support for experiments
- Corporate sponsors to keep the OSS dream alive
They're serious about community
![](https://s3.amazonaws.com/media-p.slid.es/uploads/305792/images/4876944/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/305792/images/4876965/pasted-from-clipboard.png)
One of my favorite Dash apps
@adrianomy
What I am most excited about
Interactive tables (experimental)
Cross-filtering
![](https://user-images.githubusercontent.com/1280389/30086123-97c58bde-9267-11e7-98a0-7f626de5199a.gif)
![](https://github.com/plotly/dash-table-experiments/raw/master/images/Editable-DataTable.gif)
A science example
- Resonant Ultrasound Spectroscopy is a technique to apply vibrations to a material to determine the stiffness of the material
- provides some sense of material properties w/o destroying a sample
- reverse solution is robustly available (known stiffness, unknown peaks)
- forward solution (known peaks, unknown stiffness) does not exist
- can only be solved through iteration
- local minima can be a $@#&*#@^
- visualization is helpful
A science demo
![](https://media.giphy.com/media/jkSvCVEXWlOla/giphy.gif)
So. how do i haz Dash?
pip install dash==0.21.1 # The core dash backend
pip install dash-renderer==0.12.1 # The dash front-end
pip install dash-html-components==0.10.1 # HTML components
pip install dash-core-components==0.22.1 # Supercharged components
pip install plotly --upgrade # Plotly graphing library used in examples
![](https://media.giphy.com/media/CXcZMAbkAQbF6/giphy.gif)
"install and upgrade often" - magic sloth
i know.
![](https://imgs.xkcd.com/comics/python_environment.png)
plotly's guide to deploy
Deploy? What about containers?
![](https://imgs.xkcd.com/comics/containers.png)
Docker can (should) be used
https://hub.docker.com/r/michaelerasmus/dash/~/dockerfile/
But still. When all else fails. Clean.
# Delete every Docker containers
# Must be run first because images are attached to containers
docker rm -f $(docker ps -a -q)
# Delete every Docker image
docker rmi -f $(docker images -q)
Isn't the title of this talk, Dash - using your Python beyond a dashboard in the galaxy?
Glad you asked.
![](https://s3.amazonaws.com/media-p.slid.es/uploads/305792/images/4875809/pasted-from-clipboard.png)
KnoxPy: Inside Dash
By Alex Pawlowski
KnoxPy: Inside Dash
Presented at the May KnoxPy meetup.
- 806