rich.progress

class rich.progress.BarColumn(bar_width: Optional[int] = 40, style: Union[str, Style] = 'bar.back', complete_style: Union[str, Style] = 'bar.complete', finished_style: Union[str, Style] = 'bar.finished', pulse_style: Union[str, Style] = 'bar.pulse', table_column: Optional[rich.table.Column] = None)[source]

Renders a visual progress bar.

Parameters
  • bar_width (Optional[int], optional) – Width of bar or None for full width. Defaults to 40.

  • style (StyleType, optional) – Style for the bar background. Defaults to “bar.back”.

  • complete_style (StyleType, optional) – Style for the completed bar. Defaults to “bar.complete”.

  • finished_style (StyleType, optional) – Style for a finished bar. Defaults to “bar.done”.

  • pulse_style (StyleType, optional) – Style for pulsing bars. Defaults to “bar.pulse”.

render(task: rich.progress.Task)rich.progress_bar.ProgressBar[source]

Gets a progress bar widget for a task.

class rich.progress.DownloadColumn(binary_units: bool = False, table_column: Optional[rich.table.Column] = None)[source]

Renders file size downloaded and total, e.g. ‘0.5/2.3 GB’.

Parameters

binary_units (bool, optional) – Use binary units, KiB, MiB etc. Defaults to False.

render(task: rich.progress.Task)rich.text.Text[source]

Calculate common unit for completed and total.

class rich.progress.FileSizeColumn(table_column: Optional[rich.table.Column] = None)[source]

Renders completed filesize.

render(task: rich.progress.Task)rich.text.Text[source]

Show data completed.

class rich.progress.Progress(*columns: Union[str, rich.progress.ProgressColumn], console: Optional[rich.console.Console] = None, auto_refresh: bool = True, refresh_per_second: float = 10, speed_estimate_period: float = 30.0, transient: bool = False, redirect_stdout: bool = True, redirect_stderr: bool = True, get_time: Optional[Callable[], float]] = None, disable: bool = False, expand: bool = False)[source]

Renders an auto-updating progress bar(s).

Parameters
  • console (Console, optional) – Optional Console instance. Default will an internal Console instance writing to stdout.

  • auto_refresh (bool, optional) – Enable auto refresh. If disabled, you will need to call refresh().

  • refresh_per_second (Optional[float], optional) – Number of times per second to refresh the progress information or None to use default (10). Defaults to None.

  • speed_estimate_period – (float, optional): Period (in seconds) used to calculate the speed estimate. Defaults to 30.

  • transient – (bool, optional): Clear the progress on exit. Defaults to False.

  • redirect_stdout – (bool, optional): Enable redirection of stdout, so print may be used. Defaults to True.

  • redirect_stderr – (bool, optional): Enable redirection of stderr. Defaults to True.

  • get_time – (Callable, optional): A callable that gets the current time, or None to use Console.get_time. Defaults to None.

  • disable (bool, optional) – Disable progress display. Defaults to False

  • expand (bool, optional) – Expand tasks table to fit width. Defaults to False.

add_task(description: str, start: bool = True, total: float = 100.0, completed: int = 0, visible: bool = True, **fields: Any)TaskID[source]

Add a new ‘task’ to the Progress display.

Parameters
  • description (str) – A description of the task.

  • start (bool, optional) – Start the task immediately (to calculate elapsed time). If set to False, you will need to call start manually. Defaults to True.

  • total (float, optional) – Number of total steps in the progress if know. Defaults to 100.

  • completed (int, optional) – Number of steps completed so far.. Defaults to 0.

  • visible (bool, optional) – Enable display of the task. Defaults to True.

  • **fields (str) – Additional data fields required for rendering.

Returns

An ID you can use when calling update.

Return type

TaskID

advance(task_id: TaskID, advance: float = 1)None[source]

Advance task by a number of steps.

Parameters
  • task_id (TaskID) – ID of task.

  • advance (float) – Number of steps to advance. Default is 1.

property finished: bool

Check if all tasks have been completed.

get_renderable()Union[rich.console.ConsoleRenderable, rich.console.RichCast, str][source]

Get a renderable for the progress display.

get_renderables()Iterable[Union[rich.console.ConsoleRenderable, rich.console.RichCast, str]][source]

Get a number of renderables for the progress display.

make_tasks_table(tasks: Iterable[rich.progress.Task])rich.table.Table[source]

Get a table to render the Progress display.

Parameters

tasks (Iterable[Task]) – An iterable of Task instances, one per row of the table.

Returns

A table instance.

Return type

Table

refresh()None[source]

Refresh (render) the progress information.

remove_task(task_id: TaskID)None[source]

Delete a task if it exists.

Parameters

task_id (TaskID) – A task ID.

reset(task_id: TaskID, *, start: bool = True, total: Optional[float] = None, completed: int = 0, visible: Optional[bool] = None, description: Optional[str] = None, **fields: Any)None[source]

Reset a task so completed is 0 and the clock is reset.

Parameters
  • task_id (TaskID) – ID of task.

  • start (bool, optional) – Start the task after reset. Defaults to True.

  • total (float, optional) – New total steps in task, or None to use current total. Defaults to None.

  • completed (int, optional) – Number of steps completed. Defaults to 0.

  • **fields (str) – Additional data fields required for rendering.

start()None[source]

Start the progress display.

start_task(task_id: TaskID)None[source]

Start a task.

Starts a task (used when calculating elapsed time). You may need to call this manually, if you called add_task with start=False.

Parameters

task_id (TaskID) – ID of task.

stop()None[source]

Stop the progress display.

stop_task(task_id: TaskID)None[source]

Stop a task.

This will freeze the elapsed time on the task.

Parameters

task_id (TaskID) – ID of task.

property task_ids: List[TaskID]

A list of task IDs.

property tasks: List[rich.progress.Task]

Get a list of Task instances.

track(sequence: Union[Iterable[rich.progress.ProgressType], Sequence[rich.progress.ProgressType]], total: Optional[float] = None, task_id: Optional[TaskID] = None, description: str = 'Working...', update_period: float = 0.1)Iterable[rich.progress.ProgressType][source]

Track progress by iterating over a sequence.

Parameters
  • sequence (Sequence[ProgressType]) – A sequence of values you want to iterate over and track progress.

  • total – (float, optional): Total number of steps. Default is len(sequence).

  • task_id – (TaskID): Task to track. Default is new task.

  • description – (str, optional): Description of task, if new task is created.

  • update_period (float, optional) – Minimum time (in seconds) between calls to update(). Defaults to 0.1.

Returns

An iterable of values taken from the provided sequence.

Return type

Iterable[ProgressType]

update(task_id: TaskID, *, total: Optional[float] = None, completed: Optional[float] = None, advance: Optional[float] = None, description: Optional[str] = None, visible: Optional[bool] = None, refresh: bool = False, **fields: Any)None[source]

Update information associated with a task.

Parameters
  • task_id (TaskID) – Task id (returned by add_task).

  • total (float, optional) – Updates task.total if not None.

  • completed (float, optional) – Updates task.completed if not None.

  • advance (float, optional) – Add a value to task.completed if not None.

  • description (str, optional) – Change task description if not None.

  • visible (bool, optional) – Set visible flag if not None.

  • refresh (bool) – Force a refresh of progress information. Default is False.

  • **fields (Any) – Additional data fields required for rendering.

class rich.progress.ProgressColumn(table_column: Optional[rich.table.Column] = None)[source]

Base class for a widget to use in progress display.

get_table_column()rich.table.Column[source]

Get a table column, used to build tasks table.

abstract render(task: rich.progress.Task)Union[rich.console.ConsoleRenderable, rich.console.RichCast, str][source]

Should return a renderable object.

class rich.progress.ProgressSample(timestamp: float, completed: float)[source]

Sample of progress for a given time.

property completed

Number of steps completed.

property timestamp

Timestamp of sample.

class rich.progress.RenderableColumn(renderable: Union[rich.console.ConsoleRenderable, rich.console.RichCast, str] = '', *, table_column: Optional[rich.table.Column] = None)[source]

A column to insert an arbitrary column.

Parameters

renderable (RenderableType, optional) – Any renderable. Defaults to empty string.

render(task: rich.progress.Task)Union[rich.console.ConsoleRenderable, rich.console.RichCast, str][source]

Should return a renderable object.

class rich.progress.SpinnerColumn(spinner_name: str = 'dots', style: Optional[Union[str, Style]] = 'progress.spinner', speed: float = 1.0, finished_text: Union[str, Text] = ' ', table_column: Optional[rich.table.Column] = None)[source]

A column with a ‘spinner’ animation.

Parameters
  • spinner_name (str, optional) – Name of spinner animation. Defaults to “dots”.

  • style (StyleType, optional) – Style of spinner. Defaults to “progress.spinner”.

  • speed (float, optional) – Speed factor of spinner. Defaults to 1.0.

  • finished_text (TextType, optional) – Text used when task is finished. Defaults to ” “.

render(task: rich.progress.Task)Union[rich.console.ConsoleRenderable, rich.console.RichCast, str][source]

Should return a renderable object.

set_spinner(spinner_name: str, spinner_style: Optional[Union[str, Style]] = 'progress.spinner', speed: float = 1.0)None[source]

Set a new spinner.

Parameters
  • spinner_name (str) – Spinner name, see python -m rich.spinner.

  • spinner_style (Optional[StyleType], optional) – Spinner style. Defaults to “progress.spinner”.

  • speed (float, optional) – Speed factor of spinner. Defaults to 1.0.

class rich.progress.Task(id: TaskID, description: str, total: float, completed: float, _get_time: Callable[[], float], finished_time: Optional[float] = None, visible: bool = True, fields: Dict[str, Any] = <factory>, finished_speed: Optional[float] = None, _lock: threading.RLock = <factory>)[source]

Information regarding a progress task.

This object should be considered read-only outside of the Progress class.

completed: float

Number of steps completed

Type

float

description: str

Description of the task.

Type

str

property elapsed: Optional[float]

Time elapsed since task was started, or None if the task hasn’t started.

Type

Optional[float]

fields: Dict[str, Any]

Arbitrary fields passed in via Progress.update.

Type

dict

property finished: bool

Check if the task has finished.

finished_speed: Optional[float] = None

The last speed for a finshed task.

Type

Optional[float]

finished_time: Optional[float] = None

Time task was finished.

Type

float

get_time()float[source]

float: Get the current time, in seconds.

id: TaskID

Task ID associated with this task (used in Progress methods).

property percentage: float

Get progress of task as a percentage.

Type

float

property remaining: float

Get the number of steps remaining.

Type

float

property speed: Optional[float]

Get the estimated speed in steps per second.

Type

Optional[float]

start_time: Optional[float] = None

Time this task was started, or None if not started.

Type

Optional[float]

property started: bool

Check if the task as started.

Type

bool

stop_time: Optional[float] = None

Time this task was stopped, or None if not stopped.

Type

Optional[float]

property time_remaining: Optional[float]

Get estimated time to completion, or None if no data.

Type

Optional[float]

total: float

Total number of steps in this task.

Type

str

visible: bool = True

Indicates if this task is visible in the progress display.

Type

bool

class rich.progress.TextColumn(text_format: str, style: Union[str, Style] = 'none', justify: typing_extensions.Literal[default, left, center, right, full] = 'left', markup: bool = True, highlighter: Optional[rich.highlighter.Highlighter] = None, table_column: Optional[rich.table.Column] = None)[source]

A column containing text.

render(task: rich.progress.Task)rich.text.Text[source]

Should return a renderable object.

class rich.progress.TimeElapsedColumn(table_column: Optional[rich.table.Column] = None)[source]

Renders time elapsed.

render(task: rich.progress.Task)rich.text.Text[source]

Show time remaining.

class rich.progress.TimeRemainingColumn(table_column: Optional[rich.table.Column] = None)[source]

Renders estimated time remaining.

render(task: rich.progress.Task)rich.text.Text[source]

Show time remaining.

class rich.progress.TotalFileSizeColumn(table_column: Optional[rich.table.Column] = None)[source]

Renders total filesize.

render(task: rich.progress.Task)rich.text.Text[source]

Show data completed.

class rich.progress.TransferSpeedColumn(table_column: Optional[rich.table.Column] = None)[source]

Renders human readable transfer speed.

render(task: rich.progress.Task)rich.text.Text[source]

Show data transfer speed.

rich.progress.track(sequence: Union[Sequence[rich.progress.ProgressType], Iterable[rich.progress.ProgressType]], description: str = 'Working...', total: Optional[float] = None, auto_refresh: bool = True, console: Optional[rich.console.Console] = None, transient: bool = False, get_time: Optional[Callable[], float]] = None, refresh_per_second: float = 10, style: Union[str, Style] = 'bar.back', complete_style: Union[str, Style] = 'bar.complete', finished_style: Union[str, Style] = 'bar.finished', pulse_style: Union[str, Style] = 'bar.pulse', update_period: float = 0.1, disable: bool = False)Iterable[rich.progress.ProgressType][source]

Track progress by iterating over a sequence.

Parameters
  • sequence (Iterable[ProgressType]) – A sequence (must support “len”) you wish to iterate over.

  • description (str, optional) – Description of task show next to progress bar. Defaults to “Working”.

  • total – (float, optional): Total number of steps. Default is len(sequence).

  • auto_refresh (bool, optional) – Automatic refresh, disable to force a refresh after each iteration. Default is True.

  • transient – (bool, optional): Clear the progress on exit. Defaults to False.

  • console (Console, optional) – Console to write to. Default creates internal Console instance.

  • refresh_per_second (float) – Number of times per second to refresh the progress information. Defaults to 10.

  • style (StyleType, optional) – Style for the bar background. Defaults to “bar.back”.

  • complete_style (StyleType, optional) – Style for the completed bar. Defaults to “bar.complete”.

  • finished_style (StyleType, optional) – Style for a finished bar. Defaults to “bar.done”.

  • pulse_style (StyleType, optional) – Style for pulsing bars. Defaults to “bar.pulse”.

  • update_period (float, optional) – Minimum time (in seconds) between calls to update(). Defaults to 0.1.

  • disable (bool, optional) – Disable display of progress.

Returns

An iterable of the values in the sequence.

Return type

Iterable[ProgressType]