Items missing when adding several accordion children from a loop in long-running callback using set_props

Hi there!

Pretty new to dash, trying to run a callback that makes several http requests(in a loop) and calls set_props with a Patch on an Accordion for adding an item based on an info from the responce.

The case is that not all calls to set_props causes adding new Accordion children, about 2/3 is missing, can’t get the cause.

Have read dcc.Store is used for storing data and a callback on Store changes should add children item to a UI, but not sure I got the idea right.

Here is the code

@app.callback(
    Output("dists", "label"),
    Input("update-dists-button", "n_clicks"),
    prevent_initial_call=True,
    background=True,
    manager=background_callback_manager,
    running=[
        (Output("update-dists-button", "disabled"), True, False),
    ],
)
def drawer_demo(n_clicks):
    def callback(dist,release,release_file):
        p = Patch()
        image = app.get_asset_url("logo-debian.png" if dist.startswith('debian') else 'logo-sber.png')
        p.append(dmc.AccordionItem(
            [create_accordion_label(dist, image, release), create_accordion_content(release_file),],
            value=("%s_%s" % (dist,release)),
            id="%s_%s" % (dist,release)
        ))
        print('inserting %s/%s (%s)' % (dist,release,release_file))
        set_props("dists", { "children": p })
        drawer_demo.counter = getattr(drawer_demo, "counter", 0) + 1
        print(f"Function called {drawer_demo.counter} times")

    list_http_resources("http://some_url", callback)


    return ""

And having similar issue with Cytoscape - passing huge children amount causes only a subset of an items being displayed in cytoscape. If fire a callback again - number of items in cytoscape (checked via debug panel) is increasing till it reaches that passed from a callback.

@app.callback(
    dash.dependencies.Output('cytoscape-compound', 'elements'),
    dash.dependencies.Input('submit-val', 'n_clicks'),
    dash.dependencies.State('dropdown-distributions', 'value'),
    dash.dependencies.State('dropdown-releases', 'value'),
    dash.dependencies.State('dropdown-packages', 'value'),
    dash.dependencies.State('dropdown-versions', 'value'),
    running=[(dash.dependencies.Output("submit-val", "disabled"), True, False)]
)
def update_output(n_clicks, distrib, release, package, version):
    ........
    print("--------------------------------------------------")
    print(json.dumps(nodes, indent=2))
    print("sending %i children" % (len(nodes)))
    print("--------------------------------------------------")
    return nodes

i.e. number of nodes sent from a callback equals those seen in Cytoscape after callback is fired several times.

Looks I’m missing some key point for dynamically adding UI elements from a callback, can’t somebody please enlighten?

Thanks in advance!