utils.track()

Wrap an iterable with a progress bar.

Usage

Source

utils.track(
    iterable,
    total=None,
    desc="Working…",
    unit="it",
    leave=True,
    colour=None,
    smoothing=0.3,
    **kwargs
)

This is the single entry-point for progress display used throughout seapig. When progress is disabled the iterable is returned as-is with zero overhead.

Parameters

iterable: Iterable[T]

The iterable to wrap.

total: int | None = None

Total number of items (used by tqdm/rich to render a progress bar).

desc: str = "Working…"

Short description shown to the left of the bar.

unit: str = "it"

Unit label shown after the counter (tqdm only).

leave: bool = True

Whether to keep the progress bar visible after completion (tqdm only; rich always removes it).

colour: str | None = None

Colour of the progress bar as a CSS colour string, e.g. "green" (tqdm only).

smoothing: float = 0.3

Exponential moving-average smoothing factor for speed estimates (tqdm only).

**kwargs: Any
Additional keyword arguments forwarded verbatim to the backend.

Yields

T
Items from iterable, unchanged.

Examples

>>> from seapig.utils.progress import track, disable
>>> disable()
>>> list(track([1, 2, 3], desc="items"))
[1, 2, 3]