Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delayed App Config #1876

Merged
merged 6 commits into from Jan 11, 2022
Merged

Delayed App Config #1876

merged 6 commits into from Jan 11, 2022

Conversation

bormanjo
Copy link
Contributor

@bormanjo bormanjo commented Jan 2, 2022

Adds the ability to set/update Dash.config attributes via **kwargs passed to Dash.init_app().

Contributor Checklist

  • I have broken down my PR scope into the following TODO tasks
    • Make AttributeDict additive
    • Update Dash.__init__() and Dash.init_app()
  • I have run the tests locally and they passed. (refer to testing section in contributing)
  • I have added tests, or extended existing tests, to cover any new features or bugs fixed in this PR

Alternative Multi-Page App Example

The delayed app config allows app routes to be decoupled from Dash.__init__() when server=False

from dash import Dash, html
from flask import Flask

server = Flask(__name__)

app1 = Dash(name='app1', server=False)
app1.layout = html.Div('This is App1')

app2 = Dash(name='app2', server=False)
app2.layout = html.Div('This is App2')

routes = {
    '/dash-app1/': app1,
    '/dash-app2/': app2,
}

for route, app in routes.items():
    app.init_app(server, routes_pathname_prefix=route, requests_pathname_prefix=route)


@server.route('/')
def index():
    return "<p>Hello, World!</p>"

server.run()

._read_only attribute is now a dict of name -> msgs

Overrides .update() method to use __setitem__ implementation

Includes updates to unit tests
@jborman-exos
Copy link

@alexcjohnson Thoughts on this? The two percy render tests that failed appear to be issues over the change in month/year (e.g expected December 2021, got January 2022)

dash/dash.py Outdated Show resolved Hide resolved
@jborman-exos
Copy link

@alexcjohnson Does this look good to approve + merge?

Copy link
Contributor

@alexcjohnson alexcjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks very much @jborman-exos! 💃

@t89
Copy link

t89 commented Jan 30, 2022

This set of changes seems to cause an incompatibility with jupyter-dash 0.4.0: plotly/jupyter-dash#75 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants