Split large streamlit files into multiple ones

Hello,

I have a streamlit app that I tried to organize as good as possible. After segmenting my code in multiple files, I found my streamlit file app still to large.
For now (not finished yet), the app.py have 500+ lines.
I would like to end up with an app.py file around 100 lines.

There is around 300+ lines for functions, 50+ lines for @st.dialog decorator functions, 100+ lines to write detailed component such as st.expander and others, and 50+ lines for small things.

I find it difficult to properly segment the codes, since, a lot of my function make use or change values for st.session_state or are simply @st.dialog functions.

What would be the good pratices here ?
I was looking for big streamlit project but couldn’t find one to take inspirations from.
My app is single page, but most of “good pratices” concerns muilti pages app.

All topics I found with a similar problem didn’t find a response, or in best cases, not a solution that would fit my problem.

Thank you,

You can move functions to other modules, then import those modules and call the functions from your main script

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