xsimlab.monitoring.ProgressBar

class xsimlab.monitoring.ProgressBar(frontend='auto', **kwargs)

Progress bar implementation using the tqdm package.

Examples

ProgressBar takes full advantage of RuntimeHook.

Call it as part of xarray.Dataset.xsimlab.run():

>>> from xsimlab.monitoring import ProgressBar
>>> out_ds = in_ds.xsimlab.run(model=model, hooks=[ProgressBar()])

In a context manager using the with statement:

>>> with ProgressBar():
...    out_ds = in_ds.xsimlab.run(model=model)

Globally with register method:

>>> pbar = ProgressBar()
>>> pbar.register()
>>> out_ds = in_ds.xsimlab.run(model=model)
>>> pbar.unregister()
__init__(frontend='auto', **kwargs)
Parameters
  • frontend ({"auto", "console", "gui", "notebook"}, optional) – Selects a frontend for displaying the progress bar. By default (“auto”), the frontend is chosen by guessing in which environment the simulation is run. The “console” frontend displays an ascii progress bar, while the “gui” frontend is based on matplotlib and the “notebook” frontend is based on ipywidgets.

  • **kwargs (dict, optional) – Arbitrary keyword arguments for progress bar customization. See https://tqdm.github.io/docs/tqdm/.

Methods

__init__([frontend])

param frontend

Selects a frontend for displaying the progress bar. By default (“auto”),

close_bar(model, context, state)

init_bar(model, context, state)

register()

Globally register this RuntimeHook instance.

unregister()

Globally unresgister this RuntimeHook instance.

update_finalize(model, context, state)

update_init(model, context, state)

update_run_step(model, context, state)

Attributes

active