From c76f6586ebc34a113ff35c0bb1f5a20a81dfe0a0 Mon Sep 17 00:00:00 2001 From: Hagen Wierstorf Date: Fri, 5 Jul 2024 10:35:19 +0200 Subject: [PATCH 1/3] Use better variable name for progress bar --- audeer/core/utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/audeer/core/utils.py b/audeer/core/utils.py index f66397b..4e51a2c 100644 --- a/audeer/core/utils.py +++ b/audeer/core/utils.py @@ -16,7 +16,7 @@ import uuid import warnings -from audeer.core import tqdm +from audeer.core.tqdm import progress_bar as audeer_progress_bar from audeer.core.version import LooseVersion @@ -577,7 +577,7 @@ def run_tasks( results = [None] * num_tasks if num_workers == 1: # sequential - with tqdm.progress_bar( + with audeer_progress_bar( params, total=len(params), desc=task_description, @@ -592,7 +592,7 @@ def run_tasks( else: executor = concurrent.futures.ThreadPoolExecutor with executor(max_workers=num_workers) as pool: - with tqdm.progress_bar( + with audeer_progress_bar( total=len(params), desc=task_description, disable=not progress_bar, @@ -668,7 +668,7 @@ def run_worker_threads( class QueueWithProgbar(queue.Queue): def __init__(self, num_tasks, maxsize=0): super().__init__(maxsize) - self.pbar = tqdm.progress_bar( + self.pbar = audeer_progress_bar( total=num_tasks, desc=task_description, ) From 8289079b492ff1572ec706b248c93f148b847279 Mon Sep 17 00:00:00 2001 From: Hagen Wierstorf Date: Fri, 5 Jul 2024 10:37:47 +0200 Subject: [PATCH 2/3] Add maximum_refresh_time to run_tasks() --- audeer/core/utils.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/audeer/core/utils.py b/audeer/core/utils.py index 4e51a2c..19c4347 100644 --- a/audeer/core/utils.py +++ b/audeer/core/utils.py @@ -562,6 +562,11 @@ def run_tasks( progress_bar: show a progress bar task_description: task description that will be displayed next to progress bar + maximum_refresh_time: refresh the progress bar + at least every ``maximum_refresh_time`` seconds, + using another thread. + If ``None``, + no refreshing is enforced Returns: list of computed results @@ -581,6 +586,7 @@ def run_tasks( params, total=len(params), desc=task_description, + maximum_refresh_time=maximum_refresh_time, disable=not progress_bar, ) as pbar: for index, param in enumerate(pbar): @@ -595,6 +601,7 @@ def run_tasks( with audeer_progress_bar( total=len(params), desc=task_description, + maximum_refresh_time=maximum_refresh_time, disable=not progress_bar, ) as pbar: futures = [] From ed5bbc41fb5281b03883f39f83db4ca528de5344 Mon Sep 17 00:00:00 2001 From: Hagen Wierstorf Date: Fri, 5 Jul 2024 11:30:39 +0200 Subject: [PATCH 3/3] Fix rebase --- audeer/core/utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/audeer/core/utils.py b/audeer/core/utils.py index 19c4347..bb207da 100644 --- a/audeer/core/utils.py +++ b/audeer/core/utils.py @@ -541,6 +541,7 @@ def run_tasks( multiprocessing: bool = False, progress_bar: bool = False, task_description: str = None, + maximum_refresh_time: float = None, ) -> typing.List[typing.Any]: r"""Run parallel tasks using multprocessing.