I made an app which takes in scripts and executes them, creating instances of custom modeling classes. A user can select multiple datasets from a list of datasets and use the modeling classes to make predictions on all the chosen datasets and store these predictions in the model objects themselves (as dictionaries, with the dataset filename as a key).
This is basically what the app looks like:
@st.cache(allow_output_mutation = True, show_spinner = False)
def make_predictions_w_model_classes(dataset_list):
# use custom classes to make predictions on each dataset in
# the list, store these results in the model objects themselves
return model_objs_w_data
@st.cache(allow_output_mutation = True, show_spinner = False)
def make_line_plot(dataset, line_plot_arg1, line_plot_arg2):
# use predicted obs in the model objects on dataset to make plot
return line_plot_fig
@st.cache(allow_output_mutation = True, show_spinner = False)
def make_heatmap(dataset, heatmap_arg1, heatmap_arg2):
# use predicted obs in model objects on dataset to make heatmap
return heatmap_fig
dataset_list_subset = st.multiselect("Choose datasets to make predictions", dataset_list)
model_objs =
make_predictions_w_model_classes(dataset_list_subset)
user_chosen_dataset = st.sidebar.radio(dataset_list_subset)
line_plot_arg1 = st.radio(line_plot_arg1_list)
line_plot_arg2 = st.radio(line_plot_arg2_list)
line_plot_fig = make_line_plot(user_chosen_dataset, line_plot_arg1, line_plot_arg2)
st.plotly_chart(line_plot_fig)
heatmap_arg1 = st.radio(heatmap_arg1_list)
heatmap_arg2 = st.radio(heatmap_arg2_list)
heatmap_fig = make_heatmap(user_chosen_dataset, heatmap_arg1, heatmap_arg2)
st.plotly_chart(heatmap_fig)
I’m fairly certain no computation is being done after widget interaction, since the initial computations take ~30s to do and the plots take much less time to re-render, but why would all (presumably cached) plots need to re-render when I’m interacting with widgets pertaining to one? Is there some overhead associated showing these plots on the browser? Is that overhead greater when displaying more complex plots (e.g. a heatmap controlled by a sliderbar) or a large number of plots? The plots are created almost instantly in Jupyter Notebooks.
Thanks!