I have the missing ReportContext error with the following code:
import streamlit as st
from stqdm import stqdm
from joblib import Parallel, delayed
data = Parallel(n_jobs=-1)(delayed(get_data)(*get_id) \
for get_id in stqdm(request_ids.itertuples(index=False), \
total=request_ids.shape[0])
where my get_data function gets some data using some requests.
the code runs fine without streamlit.
Any ideas ?
from time import sleep
from joblib import Parallel, delayed
import streamlit as st
def get_data(*args):
sleep(0.5)
return args
request_ids = ((str(i),) for i in range(5000))
data = Parallel(n_jobs=-1)(
st.write(get_id) or delayed(get_data)(*get_id) for get_id in request_ids
)
From my understanding so far, it’s not directly related with stqdm but more with using streamlit from the main thread of joblib.Parallel (the job provider).
I am not versed enough in joblib.Parallel, but you need to use streamlit.scriptrunner.add_script_run_ctx or your streamlit version equivalent on the thread.
To be honest, I tried to poke a bit around with joblib and streamlit but was not really successful.
My last attempt was to use manager,Namespace(). Unfortunately the context provided by streamlit add_report_ctx was not pickable and I could not really spend more time on it.
I think the question would be best asked to streamlit runner or a joblib expert.
Did you try to create an issue on either of the repos ? I could support you on this.
Hi @Wirg, it seems you didn’t understand was @Bhargav_Choithwani was trying to say. Let me try to demonstrate it with a small reproducible code.
from time import sleep
from stqdm import stqdm
import streamlit as st
submit = st.button('Click me')
if submit:
for _ in stqdm(range(50)):
sleep(0.5)
The problem is, if you stop the execution while a for loop enclosed in stqm is running, in the next re-run the code enclosed in the stqdm-ed for loop becomes non-functional. It reaches executes upto the point of the for loop but no further and just the running indication by streamlit perpetually stays in the top right corner of the screen. It is demonstrated below.
Hope this helps to understand the bug!
Edit: Just wanted to mention, this makes debugging the code enclosed in stqdm very annoying.
Hi, I have exactly the same problem. The progress bar looks awesome, but if you stop it and try to run it again, the bar will just not show up again, just like @PSP and @Bhargav_Choithwani reported. Any updates on this, @Wirg ???
Hi @Wirg,
I am not familiar with either tqdm nor STqdm, so this question might be a bit naive: Is it possible to use STqdm (tqdm) to display some kind of progress bar for a running SQL query that is fired upon clicking a st.button?
I am asking because the tqdm readme mentions in section IPython/Jupyter Integration also a mode for a progress bars without ETA (even though it is not shown in the included images).
I’d imagine that SQL queries won’t have any ETA, since you won’t know the number of result records in advance, but still you might be able to display some kind of progress bar thus indicating to the user, that the query is running and retrieving records at the speed of x/sec?
Thank you.
By stopping, I mean pressing the “Stop” icon/text/button that is present in the top right corner of any Streamlit app (at least by default). You can see my cursor pressing “Stop” in the gif in my previous post.
Yes, it should work with something like this for example.
In general, every tqdm example should work with stqdm.
There are a few limitation mainly with some weird interaction between multithreading and streamlit. But it works in general.
Note, somebody reported that progress without a total or a length is not working in stqdm v0.0.4.
There will be in v0.0.5.
@Wirg this is great and I have been trying to use it in my streamlit app but can’t figure out how to incorporate it in a for loop of user-input URLs. I’ve asked an open question on this on Stackoverflow if you or someone here is looking to beef up their reputation