A contextmanager to track progress of joblib execution using rich.progress.
The vanilla multiprocessing does not work when an object to multiprocess is not pickle-able. The joblib solves this, but then its progress is not tracked nicely. This library solves that tracking issue with joblib.
> pip install joblib-progressimport time
from joblib import Parallel, delayed
from joblib_progress import joblib_progress
def slow_square(i):
time.sleep(i / 2)
return i ** 2
with joblib_progress("Calculating square...", total=10):
Parallel(n_jobs=4)(delayed(slow_square)(number) for number in range(10))with joblib_progress("Calculating square..."):
Parallel(n_jobs=4)(delayed(slow_square)(number) for number in range(10))The idea of using joblib.parallel.BatchCompletionCallBack is referenced from https://stackoverflow.com/a/58936697/5133167