Function too long for Streamlit

Hello,

I find a difficulty when I push my code into the server. I have a function that need to create an Excel file (lot of data and Excel so it’s long ! And it is difficult to be quicker).

So when I use the tool in local, I can wait severals seconds for my file to be created (20 seconds when I hace a lot of data).

But when I use the tool online, I get the
image
and the
image

And my windows is refresh (all my data are gone).

Did you have solutions for this thing ?

I have an object that gather all the data in st.session_state[‘Data_projet’].

This object have a function that I can call like this :

st.session_state['Data_projet'].Save_Excel()

I try to use the streamlit cache like this :

@st.experimental_memo
def Data_to_Excel():
    return st.session_state['Data_projet'].Save_Excel()

The Excel file creation is call by a button :

Boutton_prep = colonnes[1].button("Prepare the Excel file")
        if Boutton_prep:
            st.experimental_memo.clear()
            colonnes[2].download_button("Export Excel", data=Data_to_Excel())

The idea is to lanch the Excel file creation and wait for the file to be ready to show the button.

The server use streamlit v1.13.0

Hey @Toto,

Thanks for sharing this question! I’d recommend upgrading to a more recent version of Streamlit and using our more up-to-date caching methods - st.cache_data in this case. That should help improve the performance of your app.

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