Code Monkey home page Code Monkey logo

Comments (4)

celia-lm avatar celia-lm commented on June 12, 2024 1

@michaelbabyn found that this change could be the cause: #1519 (this was merged in 2.7.1:

- [#2344](https://github.com/plotly/dash/pull/2344) Fix [#1519](https://github.com/plotly/dash/issues/1519), a case where dependent callbacks can be called too many times and with inconsistent inputs
)

from dash.

Lew-Goldstein avatar Lew-Goldstein commented on June 12, 2024

Hi @nicolearksey1, reaching out on this bug report as a DE customer is expecting a quick turnaround, i.e. 2 days. I know this is unrealistic, but wanted to make sure this is on your radar. Might we be able to accelerate this fix to some reasonable time frame and provide them an SLA for a patch release.

cc: @mjainGH

from dash.

michaelbabyn avatar michaelbabyn commented on June 12, 2024

I modified Celia's example slightly so that it reproduces the desired behaviour in 2.7.0 but it breaks in 2.7.1

from dash import Output, Input, html, dcc, ctx, callback
from dash_iconify import DashIconify
import dash_mantine_components as dmc
import time
import dash
import random

app = dash.Dash(__name__)
app.layout = dmc.NotificationsProvider(
    html.Div(
        [
            html.Button("click", id="btn-start"),
            html.Button("stop", id="btn-stop"),  # style={'display': 'none'}),
            html.Div(id="notify-container"),
            html.Div(id="intermediate-value", style={"display": "none"}),
        ]
    )
)

# start button updates intermediate value
@callback(
    Output("intermediate-value", "children"),
    Input("btn-start", "n_clicks"),
    prevent_initial_call=True,
)
def start_process(n_clicks):
    print("CALLBACK 0")
    return n_clicks


@callback(
    Output("btn-stop", "n_clicks"),
    Input("intermediate-value", "children"),
)
def make_api_call(nc1):
    # print("CALLBACK 1")
    # print(f"nc1: {nc1}")
    changed_id = [p["prop_id"] for p in ctx.triggered][0]
    if "intermediate" in changed_id:
        # making api call
        print("api call")
        time.sleep(3)
        return nc1
    # else :
    #     return dash.no_update


@callback(
    Output("notify-container", "children"),
    Input("btn-start", "n_clicks"),
    Input("btn-stop", "n_clicks"),
    # prevent_initial_call=True,
)
def notify(nc1, nc2):
    # print("CALLBACK 2")
    button_id = [p["prop_id"] for p in dash.callback_context.triggered][0]
    if "start" in button_id:
        return dmc.Notification(
            id="my-notification",
            title="Process initiated",
            message="The process has started.",
            loading=True,
            color="orange",
            action="show",
            autoClose=False,
            disallowClose=True,
        )
    elif "stop" in button_id:
        return dmc.Notification(
            id="my-notification",
            title="Data loaded",
            message="The process has started.",
            color="green",
            # action="show",
            action="update",
            icon=DashIconify(icon="akar-icons:circle-check"),
        )
    else:
        return dash.no_update


if __name__ == "__main__":
    app.run(debug=True, port=8021)

from dash.

Lew-Goldstein avatar Lew-Goldstein commented on June 12, 2024

See Slack thread for additional details.

from dash.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.