I have been trying to deploy an app on the cloud but it just doesn’t happen… Two days ago it was only not able to read my pickle file and threw an error but today the entire app crashed. Could anyone help me with this?
Also I’m a beginner at this so I don’t have knowlegde of things in depth.
That pickle file is too large for git alone, you need git-lfs. I think adding git-lfs to packages.txt is enough to get in installed in Streamlit Cloud. However, everything hinges on whether you are managing that large file with GitHub:
I have tried using lfs too… When I upload my file, it gets condensed to 3 lines of code while the size remains same, this is how lfs shows up when I tried to use git push --force
You are exceeding the per-file limit of 2GB for Github Free.
If you don’t need to actually keep track of changes to that file, you could serve it from somewhere else and download it once when the app runs for the first time. Something like:
import os
import shutil
import requests
import streamlit as st
bigfile_name = "my_file.pkl"
if not os.path.exists(bigfile_name):
with st.spinner("Downloading..."):
# URL to a publicly accessible link
url = "https://drive.google.com/uc?id=<YOUR-FILE-ID>&export=download&confirm=yes"
# Download and save
with requests.get(url, stream=True) as r, open(bigfile_name, "wb") as f:
shutil.copyfileobj(r.raw, f)
st.title("My App")
st.write(f"Size of `{bigfile_name}` is {os.path.getsize(bigfile_name) / 1024:.1f} KB") # Show file size
sim is just a string with the name of the pickle file. You might want to uncomment the line where you unpickle and assign the contents of that file to the sim variable.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.