@@ -93,21 +93,13 @@ def _pretask(
9393 if self ._started is None :
9494 raise ValueError ("ProgressBar not started properly" )
9595
96- if self ._pbar is None and time () - self ._started > self ._minimum :
96+ if self ._pbar is None and then - self ._started > self ._minimum :
9797 self ._init_pbar ()
9898
9999 if isinstance (key , tuple ):
100100 key = key [0 ]
101101
102- if self ._pbar is not None :
103- if self ._last_updated is None :
104- raise ValueError ("ProgressBar not started properly" )
105-
106- if time () - self ._last_updated > self ._interval :
107- self ._pbar .set_description (f"Computing { key } " )
108- self ._last_updated = time ()
109- else :
110- self ._last_task = key
102+ self ._last_task = key
111103
112104 self ._pbar_runtime += time () - then
113105
@@ -155,7 +147,10 @@ def _finish(self, _dsk: Any, _state: Dict[str, Any], _errored: bool) -> None:
155147
156148 self ._pbar_runtime += time () - then
157149
158- if self ._pbar_runtime / (time () - self ._started ) > 0.3 :
150+ if (
151+ self ._pbar_runtime > 0.1 * (time () - self ._started )
152+ and self ._pbar_runtime > 1
153+ ):
159154 print (
160155 "[ProgressBar] ProgressBar takes additional 10%+ of the computation time,"
161156 " consider disable it by passing 'progress=False' to the plot function." ,
@@ -171,6 +166,7 @@ def _update_bar(self) -> None:
171166 return
172167 ndone , _ = self ._count_tasks ()
173168
169+ self ._pbar .set_description (f"Computing { self ._last_task } " , refresh = False )
174170 self ._pbar .update (max (0 , ndone - self ._pbar .n ))
175171
176172 def _init_pbar (self ) -> None :
@@ -189,17 +185,16 @@ def _init_pbar(self) -> None:
189185 dynamic_ncols = True ,
190186 mininterval = self ._interval ,
191187 initial = ndone ,
192- desc = desc ,
193188 )
194189 else :
195190 self ._pbar = tqdm (
196191 total = ntasks ,
197192 ncols = self ._width ,
198193 mininterval = self ._interval ,
199194 initial = ndone ,
200- desc = desc ,
201195 )
202196
197+ self ._pbar .set_description (desc )
203198 self ._pbar .start_t = self ._started
204199 self ._pbar .refresh ()
205200
0 commit comments