"prevent_initial_callbacks" does not work

I noticed that option prevent_initial_callbacks stopped working.
I try to investigate, did updare dash, put commands to prevent callbacks from firing as general and for individual callbacks. Each time after starting an app all callbacks are executed.

My versions:

$ conda list dash
Name Version Build Channel
dash 1.16.3 py_0
dash-core-components 1.3.1 py_0
dash-html-components 1.0.1 py_0
dash-renderer 1.1.2 py_0
dash-table 4.4.1 py_0
jupyter-dash 0.3.0 py_0 plotly

Below is sample code from Dash documentation (modified for JupLab) where all callbacks are triggered at initialization.

Do you have idea how to prevent callbacks from firing at start?
Or, can you confirm/deny similar behaviour on your machines.

import dash
from dash.dependencies import Input, Output
import dash_html_components as html
from datetime import datetime
import time
from jupyter_dash import JupyterDash

app = JupyterDash(prevent_initial_callbacks=True)

# app = dash.Dash()

app.layout = html.Div(
        html.Button("execute callbacks", id="button_2"),
        html.Div(children="callback not executed", id="first_output_2"),
        html.Div(children="callback not executed", id="second_output_2"),
        html.Div(children="callback not executed", id="third_output_2"),
        html.Div(children="callback not executed", id="fourth_output_2"),

    [Output("first_output_2", "children"), Output("second_output_2", "children")],
    [Input("button_2", "n_clicks")], prevent_initial_call=True)
def first_callback(n):
    now = datetime.now()
    current_time = now.strftime("%H:%M:%S")
    return ["in the first callback it is " + current_time, "in the first callback it is " + current_time]

    Output("third_output_2", "children"), [Input("second_output_2", "children")], prevent_initial_call=True)
def second_callback(n):
    now = datetime.now()
    current_time = now.strftime("%H:%M:%S")
    return "in the second callback it is " + current_time

    Output("fourth_output_2", "children"),
    [Input("first_output_2", "children"), Input("third_output_2", "children")], prevent_initial_call=True)
def third_output(n, m):
    now = datetime.now()
    current_time = now.strftime("%H:%M:%S")
    return "in the third callback it is " + current_time

# if __name__ == '__main__':
#     app.run_server(debug=True)

app.run_server(mode='external', port = 8050, dev_tools_ui=True, 
          dev_tools_hot_reload =True, threaded=True) 

Hello, I have the same problem, and prevent_initial_call does has the same issue for me

I did code around this issue with if’s.
I hope when prevent_initial_callbacks will start working again on my machine I wont be forced to review the code but have no way to test it at the moment.
I still do have other issues with Dash. I noticed that some of them are /were related to security restrictions I put on my web browser. I didn’t see a list of all dependencies for Dash and mostly it is try and error method foe me.
Beside that - Dash is great and helped me, almost web illiterate, to add nice gui over my py codes.

I think this is still not resolved as I’m having the same issue

Oh, yes.
I still have dashboards with not working ‘prevents-initials’.

I also noticed other ‘deviations’ from norm when working with my dash scripts. Some of the problems I posted here but nobody offered a clear explanation.

Some of those ‘deviations’ lead me to do a little investigation. I didn’t go into depths but I suspect that there is ‘something not right’ with updating dash files in py environments.

To test it try simply to create new environment from the scratch. All newest versions.
I was only updating conda-env (I don’t use pip). When I created new one, ‘prevents’ and other issues went away.

Maybe, one day, I will do more testing, but for now, when I’m not completely in the dark, I’m ok with ‘dual standard’ environments. Will keel slowly moving my codes to the ‘standard’.

Hope this helps.

This stopped working for me as well when I updated dash. Currently on 1.19.0

Hi @Marcas @skapoor @mwveliz

If you have issues where something suddenly stops working or if you can’t run examples pulled directly from the docs, the likely cause is that Dash is not properly installed with the correct versions of all of the libraries .

Note to conda users:

If you install Dash using conda install without any other options, it installs an out-of-date version of dash-core-components and the dash renderer (and other things as well). The conda-forge channel is up-to-date, so try installing dash with :

conda install -c conda-forge dash=1.20

The OP is a good example. The version of dash 1.16.3 was the current version as of the date of the post last October, however all the other libraries are at least a year out-of-date

In the environment that’s running your app, check the version numbers of all libraries
Here’s the latest:

dash 1.20.0
dash-core-components 1.16.0
dash-daq 0.5.0
dash-html-components 1.1.3
dash-renderer 1.9.1
dash-table 4.11.3

And don’t forget about upgrading to the latest version of dash-bootstrap-components, and
if you haven’t tried dash-labs yet, I recommend installing that too and checking it out. It’s pretty cool!

dash-bootstrap-components 0.12.0
dash-labs 0.1.0

I have the same issue. I have been using workarounds with a lot of ifs, but as the app has been growing, it has become very difficult to manage. Has there been any update on this?