From 9dd0c56a3e412fc619b694ba6d3a5751c3bf2db8 Mon Sep 17 00:00:00 2001 From: Hagen Wierstorf Date: Fri, 5 Jul 2024 14:48:20 +0200 Subject: [PATCH] Update progress bar at least every second (#440) --- audb/core/define.py | 3 +++ audb/core/load.py | 6 ++++++ audb/core/load_to.py | 5 +++++ audb/core/publish.py | 5 +++++ pyproject.toml | 2 +- 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/audb/core/define.py b/audb/core/define.py index 6659b66f..dc652f2f 100644 --- a/audb/core/define.py +++ b/audb/core/define.py @@ -94,3 +94,6 @@ class Format: FORMATS = [Format.WAV, Format.FLAC] BIT_DEPTHS = [16, 24, 32] SAMPLING_RATES = [8000, 16000, 22500, 44100, 48000] + +# Progress bar +MAXIMUM_REFRESH_TIME = 1 # force progress bar to update every second diff --git a/audb/core/load.py b/audb/core/load.py index 9519bc9a..8ad1b6ff 100644 --- a/audb/core/load.py +++ b/audb/core/load.py @@ -261,6 +261,7 @@ def job(cache_root: str, file: str): num_workers=num_workers, progress_bar=verbose, task_description="Copy attachments", + maximum_refresh_time=define.MAXIMUM_REFRESH_TIME, ) audeer.rmdir(db_root_tmp) @@ -341,6 +342,7 @@ def job(cache_root: str, file: str): num_workers=num_workers, progress_bar=verbose, task_description=f"Copy {files_type}", + maximum_refresh_time=define.MAXIMUM_REFRESH_TIME, ) audeer.rmdir(db_root_tmp) @@ -398,6 +400,7 @@ def job(path: str): num_workers=num_workers, progress_bar=verbose, task_description="Load attachments", + maximum_refresh_time=define.MAXIMUM_REFRESH_TIME, ) audeer.rmdir(db_root_tmp) @@ -490,6 +493,7 @@ def job(archive: str, version: str): num_workers=num_workers, progress_bar=verbose, task_description="Load media", + maximum_refresh_time=define.MAXIMUM_REFRESH_TIME, ) audeer.rmdir(db_root_tmp) @@ -543,6 +547,7 @@ def job(table: str): num_workers=num_workers, progress_bar=verbose, task_description="Load tables", + maximum_refresh_time=define.MAXIMUM_REFRESH_TIME, ) audeer.rmdir(db_root_tmp) @@ -849,6 +854,7 @@ def job(table): num_workers=num_workers, progress_bar=verbose, task_description="Update file path", + maximum_refresh_time=define.MAXIMUM_REFRESH_TIME, ) diff --git a/audb/core/load_to.py b/audb/core/load_to.py index 93c02e30..802add98 100644 --- a/audb/core/load_to.py +++ b/audb/core/load_to.py @@ -60,6 +60,7 @@ def job(file: str): num_workers=num_workers, progress_bar=verbose, task_description="Find media", + maximum_refresh_time=define.MAXIMUM_REFRESH_TIME, ) return media @@ -97,6 +98,7 @@ def job(table: str): num_workers=num_workers, progress_bar=verbose, task_description="Find tables", + maximum_refresh_time=define.MAXIMUM_REFRESH_TIME, ) return tables @@ -146,6 +148,7 @@ def job(path: str): num_workers=num_workers, progress_bar=verbose, task_description="Load attachments", + maximum_refresh_time=define.MAXIMUM_REFRESH_TIME, ) @@ -194,6 +197,7 @@ def job(archive: str, version: str): num_workers=num_workers, progress_bar=verbose, task_description="Get media", + maximum_refresh_time=define.MAXIMUM_REFRESH_TIME, ) @@ -242,6 +246,7 @@ def job(table: str): num_workers=num_workers, progress_bar=verbose, task_description="Get tables", + maximum_refresh_time=define.MAXIMUM_REFRESH_TIME, ) diff --git a/audb/core/publish.py b/audb/core/publish.py index ac6480ef..c748e48a 100644 --- a/audb/core/publish.py +++ b/audb/core/publish.py @@ -34,6 +34,7 @@ def job(table_id): num_workers=num_workers, progress_bar=verbose, task_description="Check tables for duplicates", + maximum_refresh_time=define.MAXIMUM_REFRESH_TIME, ) @@ -227,6 +228,7 @@ def job(file): num_workers=num_workers, progress_bar=verbose, task_description="Find media", + maximum_refresh_time=define.MAXIMUM_REFRESH_TIME, ) # Add updated and new media to dependencies # and sort them by paths @@ -396,6 +398,7 @@ def job(attachment_id: str): num_workers=num_workers, progress_bar=verbose, task_description="Put attachments", + maximum_refresh_time=define.MAXIMUM_REFRESH_TIME, ) @@ -472,6 +475,7 @@ def job(archive): num_workers=num_workers, progress_bar=verbose, task_description="Put media", + maximum_refresh_time=define.MAXIMUM_REFRESH_TIME, ) deps._update_media_version(update_media, version) @@ -501,6 +505,7 @@ def job(table: str): num_workers=num_workers, progress_bar=verbose, task_description="Put tables", + maximum_refresh_time=define.MAXIMUM_REFRESH_TIME, ) diff --git a/pyproject.toml b/pyproject.toml index 12f30e7d..12460ef1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,7 +34,7 @@ classifiers = [ requires-python = '>=3.8' dependencies = [ 'audbackend[artifactory] >=2.0.0', - 'audeer >=2.0.0', + 'audeer >=2.1.0', 'audformat >=1.1.1', 'audiofile >=1.0.0', 'audobject >=0.5.0',