I’m working on a Streamlit app where I’m performing a quality check on a dataset. I want to use a progress bar to show the progress of the QC steps. However, I’ve run into an issue: the progress bar appears to be complete from the start, even though the text updates correctly as the process moves through each step.
Here is a simplified version of my code:
progress_bar = st.progress(0)
df = read.csv(file)
progress_bar.progress(10, text = “File Read")
df.head()
progress_bar.progress(20, text = “Displayed data")
df.summary()
progress_bar.progress(30, text = “Summarized data)
Despite these updates, the progress bar doesn’t seem to incrementally increase; instead, it shows as full (or nearly full) right from the start. I suspect I’m not correctly managing the progress updates in the Streamlit app.
Could someone please guide me on how to properly update the progress bar incrementally as each step is completed? I’d appreciate any tips or examples of best practices for using the st.progress function effectively.
Hey @DeeTherese ! Thanks for the question. Taking out the dataframe, I was able to update the progress bar here.
import streamlit as st
import time
progress_bar = st.progress(0)
time.sleep(2)
progress_bar.progress(10, text = "File Read")
time.sleep(2)
progress_bar.progress(20, text = "Displayed data")
time.sleep(2)
progress_bar.progress(30, text = "Summarized data")
My initial thought is simply that the dataframe happens far faster that the progress bar completes fast enough. Perhaps a video that demonstrates the problem could help?
Gotcha. Yea I am stumped. I only notice the colors are heavily changed, so I wonder if some styling is making it seem filled and not showing the progress. How are you styling it?
Hi, I haven’t added any styling to it! Here’s another sample of code. I also did add some sleep time but it made no difference.
if 'root_location' in st.session_state and 'filetype' in st.session_state:
progress_bar = st.progress(0, text="Quality check in progress. Please wait...")
root_location = st.session_state['root_location']
filetype = st.session_state['filetype']
filepath = f"{root_location}/rclif/clif_labs.{filetype}"
logger.info(f"Filepath set to {filepath}")
if os.path.exists(filepath):
logger.info(f"File {filepath} exists.")
# Start time
start_time = time.time()
progress_bar.progress(10, text='File found…')
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.