Animate dataset name+version during load/publish#556
Conversation
Reviewer's GuideIntroduces a reusable ANSI-based Sequence diagram for shimmer animation integrated into audb.load with tqdmsequenceDiagram
actor User
participant Audb as audb
participant Load as load
participant Shimmer as Shimmer
participant Backend as backend_interface
participant Tqdm as tqdm
participant Stdout as stdout
participant Stderr as stderr
User->>Audb: load(name, version, verbose=True)
Audb->>Load: load(name, version, verbose=True)
Note over Load: Setup cache paths
Load->>Shimmer: new Shimmer("Get: ", "name vversion")
Load->>Shimmer: start()
Shimmer->>Stdout: print initial line and newline
Shimmer->>Stdout: install stdout.write hook
Shimmer->>Stderr: install stderr.write hook
activate Shimmer
Shimmer-->>Shimmer: background _animate() loop
loop Dependency resolution and locking
Load->>Load: dependencies(...)
Load->>Backend: load_header_to(...)
end
loop Download with progress bars
Backend->>Tqdm: update progress
Tqdm->>Stderr: "\r...progress bar..."
Stderr->>Shimmer: stderr_write_hook("\r...")
Shimmer-->>Shimmer: set _paused = True
Shimmer-->>Stdout: write plain text frame when first paused
end
Tqdm->>Stderr: "\r ...clear...\r" or "\n"
Stderr->>Shimmer: stderr_write_hook(clear or newline)
Shimmer-->>Shimmer: set _paused = False
Shimmer-->>Stdout: resume shimmering frames
Load-->>Audb: return db
Audb-->>User: db
Load->>Shimmer: stop()
Shimmer-->>Shimmer: set stop event, join thread
Shimmer->>Stdout: restore original write
Shimmer->>Stderr: restore original write
Shimmer->>Stdout: write final static line
deactivate Shimmer
Class diagram for the new Shimmer animation utilityclassDiagram
class Shimmer {
-str _prefix
-str _text
-str _suffix
-float _interval
-int _width
-Event _stop_event
-Thread _thread
-int _lines_below
-bool _paused
-Lock _lock
-callable _original_stdout_write
-callable _original_stderr_write
+__init__(prefix, text, suffix, interval, width)
+start()
+stop()
+_stdout_write_hook(s)
+_stderr_write_hook(s)
+_write_frame(rendered_text)
+_render_frame(center)
+_animate()
+__enter__()
+__exit__(exc_type, exc_val, exc_tb)
}
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
2577c8c to
ecb2a7d
Compare
|
@audeerington, @frankenjoe |
|
Neat, I like the animation! The only thing I noticed is that the animation looks a bit choppy when loading a database that is already in cache: Screencast.from.22.05.2026.09.08.21.webmMaybe this wouldn't happen with the alternative implementation of always showing the animation, including when progress bars are active? |
|
So the idea is basically to give some feedback that the process is still running. I think it's indeed useful. |
Yes, I'd prefer it this way. I think sometimes the progress bar can also hang for a while. Not 100% sure, but during the "Update file path" part this can be the case. |
Closes #553
Alternative to #554
Adds a "shimmer" animation (bold text sweeping across the database name) to
load(),load_attachment(),load_media(),load_table(),load_to(), andpublish(). The animationruns in a background thread, pauses when
tqdmprogress bars are active, and resumes in between. A newaudb/core/shimmer.pymodule implements the animation via ANSI escape codes and stream proxying.Example video (the animation will reappear between progress bars, not shown in this video as we cancel during the first progress bar):
Screencast.from.07.04.2026.13.33.55.webm
Code for video
For
audb.load_to()andaudb.publish()we also add the following print statements to allow for the animation (before nothing was shown):As we now have an animation directly at the start, I removed showing a progress bar for downloading
db.parquetas it downloads in reasonable time and most users do not know whatdb.parquetis.An alternative implementation would be to always show the animation, also when progress bars are active:
Screencast.from.07.04.2026.13.36.20.webm