The dataiku ecosystem integrates with Shiny and Bokeh, but not Dash. From version 0.0.44, dash-extensions enables easy integrations of Dash apps as webapps in dataiku.
To get started, create a standard webapp. Make sure that the selected code environment (can be configured in the Settings tab) has the following packages installed,
and clear the JS and CSS tabs (unless you the JS/CSS code). Finally, go to the Python tab and replace the content with
import dash
import dash_html_components as html
from dash_extensions.dataiku import setup_dataiku
# Path for storing app configuration (must be writeable).
config_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "config.json")
# Create a small example app.
dash_app = dash.Dash(__name__, **setup_dataiku(app, config_path))
dash_app.layout = html.Div("Hello from Dash!")
After clicking save, you should see the text Hello from Dash! in the preview window (a backend restart might be required). Congratulations! You have created you first Dash app in dataiku.
@Emil This works like a charm - thanks so much for creating and sharing this!
There is an error I am facing, please review and let me know if you have any ideas on how to solve it. Others might benefit as well. Thanks in advance!
I run my Dash app in Dataiku as a web app, and I have been trying to simplify my somewhat large file by using a flat project layout with callbacks and layouts separated into different files, as explained towards the bottom of https://dash.plotly.com/urls . This article basically suggests to organize the dash app in 4 python files app.py, index.py, callbacks.py, layouts.py and start it by running index.py.
In Dataiku the python file that runs a webapp is backend.py. What I did is use the code from index.py (as described in the documentation link above) in my backend.py, and I import the other 3 files from a python library I created in Dataiku. Your code goes into the file app.py, except from the last line, which goes into layouts.py
So far so good, but when I try to run I get this error from the app.py file (where your code is put):
I thought it might had to do with the config_path - I also hardcoded the config path that is returned when the app runs successfully as one backend.py file, but still could not get it to work.
I cannot figure out what is going wrong (even after studying your github code) - everything runs perfectly fine if I have all my application in 1 file (backend.py).
creates a Dash object (denoted dash_app) with the dataiku provided Flask server as backend. Hence you must create the Dash object here. If you need it in other files, can pass it along, e.g. something along the lines of
@Emil that’s really awesome, thanks for sharing this!
I have one question: I would like to add authentication to my dash app and have tried using dash-auth (Add Authentication to your Dash App | Dash for Python Documentation | Plotly). When I implemented the authentication as by the example, the backend does not respond, there is no immediate error but I receive a timeout error after some time. When running the script locally on my laptop, it works fine.
Do you have any suggestions of how I could implement authentication? Is it maybe easy enough to change the .js script that you wrote to implement dash_auth?
Thanks for the quick reply @Emil, that’s a good suggestion but I think it doesn’t fit my use case.
My use case is that I want to make my webapp available to users without access to Dataiku. We can create public webapps within Dataiku since version 8 (Public webapps — Dataiku DSS 8.0 documentation). However, I want to add authentication to it so that it’s not available to everybody on the internet.