APPS: Read Only Error When Setting Up URL For App (Using Dash 2.1.0>)
Users have been getting an “AttributeError: ( Read-only: can only be set in Dash constructor or during init_app ) when trying to set up a URL for an App".
This is only happening on newer version of Dash 2.1.0 or higher. If you set the below parameters using an older version of Dash, the configuration will work and provide a working APP Url.
The sample below shows the set of lines to configure the APP Url:
Now if you use Dash greater than 2.1.0 you will get an error similar to the one below:
This can be be corrected by correcting a set of lines:
1. Remove app.config.update() call,
- Change the app = dash.Dash() as follows:
app = dash.Dash(__name__, routes_pathname_prefix='/', requests_pathname_prefix=runurl)
So for the example app, after your import statements your next bit of code would look like:
df = pd.read_csv(
'https://raw.githubusercontent.com/plotly/'
'datasets/master/gapminderDataFiveYear.csv')
# Configure Dash to recognize the URL of the container
user = os.environ.get("DOMINO_PROJECT_OWNER")
project = os.environ.get("DOMINO_PROJECT_NAME")
runid = os.environ.get("DOMINO_RUN_ID")
runurl = '/' + user + '/' + project + '/r/notebookSession/'+ runid + '/'
app = dash.Dash(__name__, routes_pathname_prefix='/', requests_pathname_prefix=runurl)
# Set layout
Comments
0 comments
Please sign in to leave a comment.