Skip to content

Error while using circular callback #137

Closed

Description

@efmanu

I was trying to play with circular callback, but I am getting the following error:

using Dash

app = dash()

app.layout = html_div() do
    dcc_slider(
        id="slider-circular",
        min=0,
        max=20,
        marks=Dict(i => "$i" for i in 0:20),
        value=3,
    ),
    dcc_input(id="input-circular", type="number", min=0, max=20, value=3)
end

callback!(
    app,
    Output("input-circular", "value"),
    Output("slider-circular", "value"),
    Input("input-circular", "value"),
    Input("slider-circular", "value"),
 ) do input_value, slider_value
    ctx = callback_context()
    trigger_id = split(ctx.triggered[1].prop_id)[1]
    trigger_id == "input-circular" ? value = input_value : slider_value
    value = (trigger_id == "input-circular") ? input_value : slider_value
    return value, value
end 
run_server(app, "0.0.0.0", 8050, debug=true)
Error is as below:
ERROR: Circular input and output arguments were found. Please verify that callback outputs are not also input arguments.
Stacktrace:
 [1] error(s::String)
   @ Base .\error.jl:33
 [2] check_callback(func::Function, app::Dash.DashApp, deps::Dash.CallbackDeps)
   @ Dash C:\Users\manoos\.julia\packages\Dash\ezFWC\src\app\callbacks.jl:181
 [3] _callback!(func::var"#25#26", app::Dash.DashApp, deps::Dash.CallbackDeps; prevent_initial_call::Nothing)
   @ Dash C:\Users\manoos\.julia\packages\Dash\ezFWC\src\app\callbacks.jl:129
 [4] callback!(::var"#25#26", ::Dash.DashApp, ::Output{String}, ::Vararg{Dash.Dependency, N} where N; prevent_initial_call::Nothing)
   @ Dash C:\Users\manoos\.julia\packages\Dash\ezFWC\src\app\callbacks.jl:108
 [5] callback!(::var"#25#26", ::Dash.DashApp, ::Output{String}, ::Output{String}, ::Input{String}, ::Input{String})
   @ Dash C:\Users\manoos\.julia\packages\Dash\ezFWC\src\app\callbacks.jl:104
 [6] top-level scope
   @ REPL[23]:1

Activity

  1. alexcjohnson commented on Oct 22, 2021

    @alexcjohnson
    Contributor

    Most of this kind of validation is done by the renderer now, so if it's still being done in Julia that's superfluous and should be removed, so it's easier to keep up with renderer changes.

    Really the only validation that should be done in Julia is type checking, to ensure the callback specs will make it to the front end intact.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions