tqdm
and dask
are both amazing packages for iterations in python. While tqdm
implements the needed progress bar, dask
implements the multi-thread platform and they both can make iteration process less frustrating. Yet - I'm having troubles to combine them both together.
For example, the following code implements a delayed execution in dask
, with tqdm.trange
progress bar. The thing is that since the delayed
is performed quickly, the progress bar ends immediately, while the real computation-time effort is done during the compute
part.
from dask import delayed,compute
from tqdm import trange
from time import sleep
ct = time()
result= []
def fun(x):
sleep(x)
return x
for i in trange(10):
result.append(delayed(fun)(i))
print compute(result)
How can I attach the progress bar to the actual execution in compute
command?