-
-
Notifications
You must be signed in to change notification settings - Fork 40
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
Support background callbacks #213
Comments
Current dash docs articles on background callbacksHistory lessonplease let me know if I'm missing anything 😄 Background callbacks in python dash were first called "long" callback. They were added via the Long callbacks were then improved and effectively renamed "background" callbacks in plotly/dash#2039 and plotly/dash#2116, released in python dash Subsequent fixes and tweaks to background callbacks were made in:
High-level designThe python dash If The supported cache managers are: Celery (paired with Redis) and Diskcache. That is, the python dash cache managers are wrappers around established python caching / queuing libraries. We should survey caching package in the Julia ecosystem that would work well for this use case. After a quick search, Dagger.jl look like a promising Celery-like package. The extra clientside logic mostly is here and here (refer to Dash.jl APIsee base python exampleimport time
import os
from dash import Dash, DiskcacheManager, Input, Output, html, callback
import diskcache
cache = diskcache.Cache("./cache")
background_callback_manager = DiskcacheManager(cache)
app = Dash(__name__)
app.layout = html.Div(
[
html.Div([html.P(id="paragraph_id", children=["Button not clicked"])]),
html.Button(id="button_id", children="Run Job!"),
]
)
@callback(
output=Output("paragraph_id", "children"),
inputs=Input("button_id", "n_clicks"),
background=True,
manager=background_callback_manager,
)
def update_clicks(n_clicks):
time.sleep(2.0)
return [f"Clicked {n_clicks} times"]
if __name__ == "__main__":
app.run(debug=True) would translate to see Dash.jl translationusing Dash
import SomeCachingPkg
app = dash()
cache = SomeCachingPkg.Cache("./cache")
manager = DiskcacheManager(cache)
app.layout = html_div() do
html_div() do
html_p("Button not clicked"; id="paragraph_id")
end,
html_button("Run Job!"; id="button_id")
end
callback!(app,
Output("paragraph_id", "children"),
Input("button_id", "n_clicks");
background=true,
manager) do n_clicks
sleep(2)
return "Clicked $n_clicks times"
end
run_server(app) |
Would be nice if we could support background callbacks on the julia side also.
Related to #110
The text was updated successfully, but these errors were encountered: