Streamlit run myapp.py is not writing the files in the project folder but running the code from python is

Summary

These functions are downloading mutiple zipfiles from an ftp server, extract the files and saving them in the project folder (where the myapp.py is).

If I run the code directly in python it works and the files are written in the project folder but if I do it on my streamlit app the code will run but the folder stays empty. There are no error messages.

I am on windows and I am running the latest version of streamlit.

Steps to reproduce

Code snippet:

@st.cache_data
def download_and_unzip(url, extract_to='.'):
    http_response = urlopen(url)
    zipfile = ZipFile(BytesIO(http_response.read()))
    zipfile.extractall(path=extract_to)

@st.cache_data
def get_storm_data():
    # unzip all files
    for zip_file in nhc_urls_list:
        url_zip_file = url + zip_file
        print("Downloading: " + url_zip_file)
        download_and_unzip(url_zip_file)

I’m not sure I understand. You have a caching decorator on functions that return no values. The purpose of caching to to save the return value of a function. If you have side effects–things being written to the screen or to a file–then you will not want to cache that function. Caching does not have any memory of the internals of a function, only the return value. The return value of those two function is None and that’s all caching knows (and cares about).

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