Dynamic list of outputs

Hello! I had some list of outputs in the following code:

normalized_features = ["a", "b", "c"]

@app.callback(
    [Output(feature, "value") for feature in normalized_features],
    Input("indices", "value"),
)
def update_features_by_index_date(index):
    ...
    return features_list

Now i want to dynamically change normalized_features like this:

@app.callback(
    Output("normalized_features", "value") ,
    Input("model", "value"),
)
def update_features(model):
    ...
    return normalized_features

How can i use these normalized_features from callback in the first case?
Is there a way to do something like this:

@app.callback(
    [Output(feature, "value") for feature in "normalized_features_from_callback"],# how should i change this line?
    Input("indices", "value"),
)
def update_features_by_index_date(index):
    ...
    return features_list

Or may be there is another approach? I have a div with Input for each feature from normalized columns and use it in further like:

@app.callback(
    Output("score", "value"),
    [Input(feature, "value") for feature in normalized_features],
)
def get_score(*features):
   ...

So every time i change “model” i want to create new “normalized_features” and recreate Output and div with input for each feature from new normalized_features

I do not fully understand but if I am to rephrase, you have a list called nomralized_features and you want to change it when something happened.
When you say list of outupts, is the list a UI component or it contains the Ids of the outputs.

If possible can you add the layout in a simplify way of what the output is all about

Hi @trinityimma

Like @trinityimma mentioned it’s not entirely clear what you are trying to do, but you may be able to use a dcc.Store component for the normalized_features list. You could start by looking at the docs: “Share data between callbacks” example here :

2 Likes

Hello! I am sorry for being unclear. I try to describe my problem in simple words.
I want to create a callback where output is a dynamically changing list: this list is an output in another callback. A dcc.Store is a good solution but i want to deal with each element of the list separately: i am going to create a div and a callback for each element in further.