Last active
March 31, 2021 18:59
-
-
Save gerritjandebruin/3aa036c8fe35a1b17d0bceb097e0e419 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import joblib | |
from tqdm.auto import tqdm | |
class ProgressParallel(joblib.Parallel): | |
def __init__(self, use_tqdm=True, total=None, desc=None, *args, **kwargs): | |
self._use_tqdm = use_tqdm | |
self._total = total | |
self._desc = desc | |
super().__init__(*args, **kwargs) | |
def __call__(self, *args, **kwargs): | |
with tqdm(disable=not self._use_tqdm, total=self._total, | |
desc=self._desc) as self._pbar: | |
return joblib.Parallel.__call__(self, *args, **kwargs) | |
def print_progress(self): | |
if self._total is None: | |
self._pbar.total = self.n_dispatched_tasks | |
self._pbar.n = self.n_completed_tasks | |
self._pbar.refresh() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment