How to avoid app reruns for data guided proposal app with multiple user_inputs

I’m looking for tips, or guidance on how to make my proposal making app faster, smoother for users.
I’ve made a data powered proposal making app that has many guided and data powered user inputs that determine upcoming selection lists, and do some quick in-situ summing/df filtering with a few chart outputs.

My problem is that I may be outgrowing streamlit, as any user interaction causes the full page to rerun which is at worst; jarring as the page repaints, and at best; slow. Moving a slider causes all plots to refresh, etc.

Forms?
I’m trying to have the user input be fun and engaging, which means updating outputs as information is entered in. I know I can lock some entries behind forms, but the extra button clicks really interrupt the workflow of the app. And it’s primary goal is speed.

Caching?
I’ve been trying to see if there’s some way of using cache_data and putting all of the user inputs into cached defs. But I haven’t had any luck so far.

callbacks?
I also wonder if callbacks may help with some of this. But I’m not an expert on using those.

I’d like some guidance from some of the more experienced Streamlit’ers on how I can prevent the full page rerun when someone selects a number from a drop down, but still have it update a background df, or possibly update some immediate sum calc that is displayed.

Thank you,

Hi @eightm

What you’re looking for is Session State, which will help to memorize the state of the app whenever a user interacts with the widgets (will not cause an app re-run).

Below please find the Docs that provides detailed examples and code snippets to get you started:

I use session_state extensively. However, whenever a user inputs a value into one of the many fields, a rerun and page refresh is still triggered. With as many plotly charts as I have painting, this is slow and jerky until fully loaded. 2-5 seconds typically.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.