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…')