dash icon indicating copy to clipboard operation
dash copied to clipboard

[BUG] Long callback doesn't work in jupyter notebook

Open wslabik opened this issue 2 years ago • 2 comments

Describe your context Please provide us your environment, so we can easily reproduce the issue.

  • replace the result of pip list | grep dash below
dash                         2.3.1
dash-bootstrap-components    1.1.0
dash-bootstrap-templates     1.0.5
dash-core-components         2.0.0
dash-extensions              0.1.3
dash-html-components         2.0.0
dash-loading-spinners        1.0.0
dash-table                   5.0.0

Describe the bug

'running options’ in long callback are not working correctly when used with JupyterDash

Expected behavior

'running options' in long callbacks should work the same way in JupyterDash as they work in regular Dash

Screenshots

Cell output in the jupyter notebook (button is never enabled): Capture

Error which showed in the cell after a while of running:

ProcessLookupError: [Errno 3] assume no such process (originated from NtQuerySystemInformation (no PID found))

During handling of the above exception, another exception occurred:

NoSuchProcess                             Traceback (most recent call last)
NoSuchProcess: psutil.NoSuchProcess process no longer exists (pid=10268)

Here example 2 from the official guide changed to use JupyterDash instead of Dash, where button is never re-enabled (the 'running option' which should been applied at the end of the callback):

from jupyter_dash import JupyterDash
import time
import dash
from dash import html
from dash.long_callback import DiskcacheLongCallbackManager
from dash.dependencies import Input, Output
import diskcache

cache = diskcache.Cache("./cache")
long_callback_manager = DiskcacheLongCallbackManager(cache)

app = JupyterDash(__name__, long_callback_manager=long_callback_manager)

app.layout = html.Div(
    [
        html.Div([html.P(id="paragraph_id", children=["Button not clicked"])]),
        html.Button(id="button_id", children="Run Job!"),
    ]
)

@app.long_callback(
    output=Output("paragraph_id", "children"),
    inputs=Input("button_id", "n_clicks"),
    running=[
        (Output("button_id", "disabled"), True, False),
    ],
)
def callback(n_clicks):
    time.sleep(2.0)
    return [f"Clicked {n_clicks} times"]


if __name__ == "__main__":
    app.run_server(debug=True, mode='inline', port=2006)

wslabik avatar May 18 '22 01:05 wslabik

To validate with the new background callbacks.

T4rk1n avatar Aug 03 '22 19:08 T4rk1n