Skip to main content

Plotly Dash Templating and Deployment Tools

Project description

🛠️ dash-tools - Easily Create and Deploy your Plotly Dash Apps from CLI (🎉 V1.0)

Create a templated multi-page Plotly Dash app with CLI in less than 7 seconds.

Deploy your app to Heroku in under a minute!

About

dash-tools is an open-source toolchain for Plotly Dash Framework. With a user-friendly command line interface, creating Dash applications 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!

Want to deploy your app to the web? We've got you covered. With Heroku support, deploying your project will take under a minute.

Installation

Ready to use dash-tools? Installation is easy with pip:

pip install dash-tools

Find dash-tools on PyPi

Usage Examples

Below are common usage examples. For a more in-depth tutorial on writing apps for Plotly Dash, see the Plotly Dash Documentation. For information about dash-tools commands, read the Commands section.

Creating A New Project

Creating a new Dash project is very simple. The following command will create a new directory called "MyDashApp" using the optional "multipage" template. Learn more about Templates below.

dash-tools --init MyDashApp multipage

Optionally, no template needs to be specified. Instead, the 'default' template will be used:

dash-tools --init MyDashApp

The previous command will create a "MyDashApp" directory. You can see what files are included with your new app:

cd MyDashApp && ls

You can make changes to your app in the src/app.py file! See https://dash.plotly.com/layout for more information.

When you are happy with your changes, run your dash app locally with the following command. You will be able to view your app at http://127.0.0.1:8050/ in your browser:

python src/app.py

Deploying To Heroku

Deploying your project online to Heroku is simple. The CLI handles both creating and deploying a new app, as well as updating an existing app.

Creating a Heroku App

To create an app, run the following command from your project's root directory; e.g. /MyDashApp from the example above. Next, follow the simple on-screen directions and deployment will be handled for you:

dash-tools --deploy-heroku

Optionally, you can specify a heroku app name as an argument. If one is not provided, you will be prompted to enter one or generate one automatically.

Note that "some-unique-heroku-app-name" in the example below is a name that you should change.

dash-tools --deploy-heroku some-unique-heroku-app-name

And that's really it! You will be prompted to log into your heroku account, a git remote 'heroku' will be created and changes will be pushed and deployed automatically.

Pushing Changes to an Existing Heroku App

To push changes to an existing heroku app after it is deployed, you can use the same command as before. Since a 'heroku' git remote already exists, by choosing the on-screen option to "Update Existing App", all changes will be pushed and your app will be re-deployed:

dash-tools --deploy-heroku

If you would rather add specific files, make a commit and push to the 'heroku' remote manually:

git add SomeFileYouModified.txt
git commit -m "Your Commit Message"
git push heroku

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.

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):

dash-tools --init MyWonderfulApp tabs

To list out available templates, use the --templates or -t command:

dash-tools --templates

Available Templates

Click the dropdowns below to see screenshots!

Template: 'advanced'

Advanced multi-page template. Includes examples of ClientsideCallbacks, multi-page routing, external stylesheets, header, footer, and 404 page.

Template: 'default'

Basic Dash template. See Dash Docs

Template: 'iris'

Iris theme. See Faculty.ai Example

Template: 'mantine'

Basic mantine template. See Dash Mantine

Template: 'multipage'

New multipage theme. See Multipage Plugin

Template: 'sidebar'

Sidebar theme. See Faculty.ai Example

Template: 'tabs'

Tabs theme with dynamically generated content. See Faculty.ai Example

Commands

Project Commands

  • --deploy-heroku Args: OPTIONAL (unique heroku project name) : Deploys the project to Heroku using the Heroku CLI (Must Install Seperately) and Git. Invoke from the project root directory.
  • --init, -i Args: REQUIRED (project name) OPTIONAL (template) : Creates a Plotly Dash app with the given name in the current working directory. Optional args specified can be used for templates.
  • --templates, -t : List available templates.

Other

  • --help, -h: Display CLI helpful hints
  • --version: Display current version.

Development

Creating Templates

  1. Templates are found here: dash_tools/templating/templates/<Template Name>. When a user uses CLI to choose a template with the name <Template Name> the template will be copied to their system.

  2. Adding a new template to the templates directory requires adding the new template to the Enum list in templating.Templates Enum. Template name must match Enum value, eg.

    class Templates(Enum):
       DEFAULT = 'default'
       MINIMAL = 'minimal'
       NEWTEMPLATE = 'newtemplate'
    
  3. Any file names or files containing the strings {appName} or {createTime} will be formatted with the given app name and creation time. Eg. README.md.template: # Created on {createTime} will copy to the user's filesystem as README.md: # Created on 2022-03-30 22:06:07

  4. All template files must end in .template

License

MIT License. See LICENSE.txt file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dash-tools-1.0.tar.gz (4.1 MB view hashes)

Uploaded Source

Built Distribution

dash_tools-1.0-py3-none-any.whl (4.1 MB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page