Is there any way to refactor large apps it into functions?

Summary

An app Iā€™m building is getting very big/long. Think 2000+ lines of mostly Streamlit code.

This is because I have some widgets, some graphs, some tabs, columns, metricsā€¦ etc.

I would like to refactor this into smaller files to manage the complexity - but I donā€™t know what is Streamlitā€™s best practice for this.

Maybe my code should look like this:

from helpers import render_widgets, render_data, render_charts, rernder_metrics

filters =  render_widgets()
selected_data = render_data(filters)
charts = render_charts(selected_data, filters)
rernder_metrics(charts, selected_data, filters)

But in this case the render_widgets function (for example) would be generating multiple columns of widgets of various kindsā€¦ etc.

To clarify, this is still a single page app.

1 Like

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