Hello everyone,
Summary
I have this app where I upload several files, save them to a temporary directory to work on them, then analyze them, and return a few pictures.
I would like to find a way to cache the analysis function given it takes too long.
However, the problem is that since I save the files to a temporary directory, whenever I make a change in pictures parameters, the scripts runs again, and since the files are in a temporary directory, the actual files change thus the long analysis function runs once more.
Steps to reproduce
The code is something like this
Code snippet:
with TemporaryDirectory() as tempDir:
saveFilesToTempDir()
longAnalysisFunction(files_in_tempDir)
variable = st.checkbox("Do something with the picture")
generatePictures(variable)
So when I check the checkbox, even if I cache the longAnalysisFunction(), given that the script runs again, tempDir changes, thus files_in_tempDir changes and the function is not cached.
Is there a way I can go around this?
The reason behind saving the files to a tempDir is that I run a few programs installed on the server on those files.
Any help is greatly appreciated!