quantlab.utils.progress.TqdmProgressReporter#

class quantlab.utils.progress.TqdmProgressReporter(*, disable=False)[source]#

Bases: ProgressReporter

Default reporter: a tqdm progress bar on stderr.

The bar is created on run_started, the first event that knows the number of batches, with the event’s message as its label. Each batch_completed advances it by one. The first quota_exhausted in a run changes the label to the event’s message (or QUOTA_EXHAUSTED_DESCRIPTION); repeats are ignored because the label describes a state that has already been shown. run_finished closes the bar. A new run_started closes any open bar and starts a fresh one, so a retry loop that makes several passes shows one bar per pass.

This reporter only reacts to acquisition events; conversion events are ignored.

Parameters:
disablebool, default False

Passed to tqdm. When true, nothing is drawn.

Examples

>>> reporter = TqdmProgressReporter()
>>> acquisition.attach(reporter=reporter).download()
close()[source]#

Close the open bar, if any.

Examples

>>> reporter = TqdmProgressReporter(disable=True)
>>> reporter.close()  # a no-op while no bar is open
emit(event)[source]#

Open, advance, relabel or close the bar according to event.

Parameters:
eventProgressEvent

The event to render. Kinds other than run_started, batch_completed, quota_exhausted and run_finished are ignored.

Examples

>>> reporter = TqdmProgressReporter(disable=True)
>>> reporter.emit(ProgressEvent(kind="run_started", vendor="tiingo",
...                             total=2, message="tiingo 1d"))
>>> reporter.emit(ProgressEvent(kind="batch_completed",
...                             vendor="tiingo", completed=1, total=2))
>>> reporter.emit(ProgressEvent(kind="run_finished", vendor="tiingo",
...                             completed=2, total=2))