Plotly Dash Templating and Deployment Tools
Project description
About
dashtools is an open-source toolchain for Plotly Dash. With a user-friendly command line interface, creating Dash applications and deploying them to Heroku has never been quicker.
Includes user and developer-friendly app templates where generating a new app only takes seconds. In fact, it will take longer to install this tool than it will to use it!
Installation
Ready to use dashtools? Installation is easy with pip:
pip install dash-tools
Requires:
- Heroku CLI which can be downloaded Here
- Git CLI which can be downloaded Here
- OS - Linux, MacOS, Windows currently supported
Usage Examples
A. Create an App
-
Create a Dash project in a new directory called "MyDashApp" (using your terminal or command prompt):
Note
"MyDashApp" can be changed to any name. However, for the purpose of this tutorial, we recommend keeping it as "MyDashApp".dashtools init MyDashApp
-
Open the default
app.py
file that comes with this project:Windows
.\MyDashApp\src\app.py
Linux and Mac OS
./MyDashApp/src/app.py
-
Replace the code in
app.py
with your own app code. Make sure to keep theserver = app.server
right after app instantiation:
-
Make sure you are in your project's root directory:
cd MyCSVApp
-
Run your app to ensure it works:
dashtools run
Deploy App to Web with Heroku
-
Deploy to Heroku:
dashtools heroku --deploy
B. Create an App with Local CSV sheet
A common use for Dash is to display CSV data that is located inside the project folder. For this, you can use the CSV Dash-tools template to create a project with CSV data.
-
Using App template with CSV
dashtools init MyCSVApp csv
-
Replace the code in
app.py
with your own app's code, like shown in example A above. Make sure to keep code lines 13, 26, and 27.- 13:
server = app.server
- 26:
PATH = pathlib.Path(__file__).parent
- 27:
DATA_PATH = PATH.joinpath("data").resolve()
- 13:
-
Replace the default CSV file in the
data
folder with your own CSV file -
Make sure you are in your project's root directory:
cd MyCSVApp
-
Run your app to ensure it works:
dashtools run
Deploy App to Web with Heroku
-
Deploy to Heroku:
dashtools heroku --deploy
Templates
Templates contain boilerplate code for Dash projects, making it much easier to start with useful baseline apps.
Using Templates
Use the optional template argument with the init
command:
dashtools init <appname> [template]
The following example will create a new app "MyWonderfulApp" (you can name your app anything) using the 'tabs' template (or any other template listed below):
dashtools init MyWonderfulApp tabs
To list out available templates, use the templates --list
command:
dashtools templates --list
Available Templates
Click the dropdowns below to see screenshots!
Template: 'advanced'
To use this template, type: dashtools init MyFuturisticApp advanced
Advanced multi-page template. Includes examples of ClientsideCallbacks, multi-page routing, external stylesheets, header, footer, and 404 page.
Template: 'csv'
To use this template, type: dashtools init MyCSVLoaderApp csv
Example of CSV file loading. Includes the default CSV load example from Plotly.
Template: 'default'
To use this template, type: dashtools init MyAmazingApp default
Basic Dash template. See Dash Docs
Template: 'iris'
To use this template, type: dashtools init MyFantasticApp iris
Iris theme. See Faculty.ai Example
Template: 'mantine'
To use this template, type: dashtools init MyGreatApp mantine
Basic mantine template. See Dash Mantine
Template: 'multipage'
To use this template, type: dashtools init MyPristineApp multipage
New multipage theme. See Multipage Plugin
Template: 'sidebar'
To use this template, type: dashtools init MySnazzyApp sidebar
Sidebar theme. See Faculty.ai Example
Template: 'tabs'
To use this template, type: dashtools init MyBeautifulApp tabs
Tabs theme with dynamically generated content. See Faculty.ai Example
Commands
Usage:
dashtools <command> [options]
Commands and Options:
heroku
Handle Heroku deployment. Choose option:--deploy
Deploys the current project to Heroku--update [remote name (OPTIONAL)]
Push changes to existing Heroku remote
init <app name> [template (OPTIONAL)]
Create a new app--dir, -d
Specify alternative create location
run
Run app locally from the current directorytemplates
List and create templates--init <directory to convert>
Creates a template from specified directory--list
List available templates
Other Options:
--help, -h
Display help message--version, -v
Display version
Troubleshooting Common Issues
Running into issues? Outlined below are common errors and solutions. If you do not find an answer below, please Submit an Issue Ticket.
Common init
Issues
No write permission
Problem: You receive a 'write permission' error while trying to init a new app
Solution: Please check your write permissions for the current directory. Try the init command from a different directory.
Common heroku --deploy
Issues
Error when creating requirements.txt file
Problem: You encounter an error when generating a requirements.txt file
Solution: Verify that you are running the dashtools heroku --deploy
command from a valid plotly dash app directory. E.g. there is a src/app.py
file.
Development
See the Developer Guide for more details.
License
MIT License. See LICENSE.txt file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.