Progress
progress
¶
Defines themed Rich progress bars for server-side oprations
One Shared Display
-
File uploads and
Modalvolume transfers report their byte progress throughtransfer_bar, a context manager that yields anadvancecallable -
All bars share a single
rich.progress.Progressobject (obtained lazily via_progress_display_manager) drawn on the shared console, so concurrent transfers (batches) render as stacked tasks in one display instead of fighting over stdout -
On a non-interactive stream (the server under Docker / uvicorn) the bars are a no-op, so nothing is written except the surrounding
LOGGERlines
Advance = Callable[[int], None]
module-attribute
¶
The signature of the advance callback called by each tracked-progress
operation with the number representing how much to advance the progress counter
CountingReader
¶
A transparent binary-reader proxy that reports every read to an
Advance callable
Why
-
The chunked uploader (Modal's
batch_upload) reads a source file itself, so the caller has no per-chunk hook to advance a progress bar -
Wrapping the file in this proxy makes each
readalso report the number of bytes returned, so the bar advances as the uploader consumes the file, without changing how the uploader reads
Transparency
-
Only
readis intercepted -
Every other attribute (
seek,tell,close,mode, ...) is delegated to the wrapped file via__getattr__, so the proxy still behaves like the binary stream the uploader expects
__getattr__(name)
¶
Delegates any non-intercepted attribute to the wrapped file
Only reached for attributes not defined on the proxy itself (so not
read), which keeps seek / tell / close / ... pointing at the
real file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The attribute being accessed |
required |
Returns:
| Type | Description |
|---|---|
object
|
The corresponding attribute of the wrapped binary file |
__init__(raw, advance)
¶
transfer_bar(description, total=None)
¶
Shows a themed byte-transfer progress bar for the duration of the block
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
description
|
str
|
The bar label |
required |
total
|
int | None
|
The total byte count, or |
None
|
Yields:
| Type | Description |
|---|---|
Advance
|
A callable which advances the bar by a number of bytes |