You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am very happy with rich output in the console application, jupyterlab use case. However when using streamlit i had the following issue.:
When using the progress bar, the progress was shown on the console i started streamlit from, not the web-browser. When 2 users wanted to do something which tried to use a progress bar, this failed.
Solution.:
classRichProgressWrapper(): """This is to allow to have multiple instances of converters active at every given time, and to have some progress information similar to what rich provides... """progress=collections.defaultdict(lambda :0) workload=collections.defaultdict(lambda :None) def__init__(self, *args): self.expectednum=0passdef__enter__(self): returnselfdef__exit__(self, *args): passdefadd_task(self, name, total): ident=threading.current_thread().identself.expectednum=totalself.workload[ident] =totaldefupdate(self, _, completed): self.progress[threading.current_thread().ident] =completed/self.expectednumrichProgressBarUser.Progress=RichProgressWrapper
And at the point where the progress bar shall be shown.:
thread=threading.Thread(target=get_data_worker, args=args) thread.start() progressbar=st.progress(0, text="") whileTrue: thread.join(timeout=3) text=""ifRichProgressWrapper.workload[thread.ident]: passed=time.time()-start_timespeed= (RichProgressWrapper.progress[thread.ident]*RichProgressWrapper.workload[thread.ident])/(passed*1e6) text=f"Working on {RichProgressWrapper.workload[thread.ident]/1e6:.1f} MB input... {passed:.3f}s have passed... {(RichProgressWrapper.progress[thread.ident]*100.0):.1f}% competed... running at {speed:.3f} MB/s "progressbar.progress(RichProgressWrapper.progress[thread.ident], text=text) ifnotthread.is_alive(): progressbar.empty() break
which provides a progressbar which does not throw an exception if multiple connections want to use the progress bar at the same time.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I am very happy with rich output in the console application, jupyterlab use case. However when using streamlit i had the following issue.:
When using the progress bar, the progress was shown on the console i started streamlit from, not the web-browser.
When 2 users wanted to do something which tried to use a progress bar, this failed.
Solution.:
And at the point where the progress bar shall be shown.:
which provides a progressbar which does not throw an exception if multiple connections want to use the progress bar at the same time.
Is there any interest in streamlit support?
Thanks in advance,
Franz
Beta Was this translation helpful? Give feedback.
All reactions