STqdm : a tqdm-like progress bar for streamlit

How can I link the progress bar with a real execution of process?
Thanks

It depends on what you exactly mean by “a real execution of process” and how your application tracks its progress.

FYI - I have updated my little test app.

Any way to use this when downloading a large file in chunks? Here is how I do it when writing to a file.

resp = requests.get(zip_url, stream=True)
                if resp.status_code == 200:
                    total = int(resp.headers.get("content-length", 0))
                    file_path = (
                        file_path if file_path else self._cache_dir / f"{zipname}.zip"
                    )
                    with open(file_path, "wb") as file, tqdm(
                        desc=f"Downloading to {file_path}",
                        total=total,
                        unit="B",
                        unit_scale=True,
                        unit_divisor=1024,
                    ) as bar:
                        for data in resp.iter_content(chunk_size=1024):
                            size = file.write(data)
                            bar.update(size)

For streamlit, i would just like to write to a variable that will be used with st.download_button

Hi @info-rchitect ,

I think it should work out of the box by just replacing tqdm by stqdm.
Do you run into any issues ?

stqdm inherit from tqdm and should expose every tqdm functionnalities (and there are a lot). :stuck_out_tongue:
It mainly changes where tqdm write (to the streamlit dashboard) and some minor issues that may be specific to streamlit (locks, managing containers …)

Did it work ?

Hello,
Is there any way to use STqdm for async tasks ?
similar to: tqdm.asyncio - tqdm documentation

This is great, Thansk a lot for this!!

1 Like