Skip to content

Commit

Permalink
Update progress bar at least every second (#440)
Browse files Browse the repository at this point in the history
  • Loading branch information
hagenw authored Jul 5, 2024
1 parent 0cc7497 commit 9dd0c56
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions audb/core/define.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions audb/core/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
)


Expand Down
5 changes: 5 additions & 0 deletions audb/core/load_to.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
)


Expand Down Expand Up @@ -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,
)


Expand Down Expand Up @@ -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,
)


Expand Down
5 changes: 5 additions & 0 deletions audb/core/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)


Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
)


Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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,
)


Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 9dd0c56

Please sign in to comment.