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')[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.bar.Bar[source]

Gets a progress bar widget for a task.

class rich.progress.DownloadColumn[source]

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

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

Calculate common unit for completed and total.

class rich.progress.FileSizeColumn[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: rich.console.Console = None, auto_refresh: bool = True, refresh_per_second: int = None, speed_estimate_period: float = 30.0, transient: bool = False, redirect_stdout: bool = True, redirect_stderr: bool = True, get_time: Callable[], float] = None)[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[int], 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_stout – (bool, optional): Enable redirection of stdout, so print may be used. Defaults to True.

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

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

add_task(description: str, start: bool = True, total: int = 100, completed: int = 0, visible: bool = True, **fields: Any) → NewType.<locals>.new_type[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 (int, 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: NewType.<locals>.new_type, 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

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

process_renderables(renderables: List[rich.console.ConsoleRenderable]) → List[rich.console.ConsoleRenderable][source]

Process renderables to restore cursor and display progress.

refresh() → None[source]

Refresh (render) the progress information.

remove_task(task_id: NewType.<locals>.new_type) → None[source]

Delete a task if it exists.

Parameters

task_id (TaskID) – A task ID.

start() → None[source]

Start the progress display.

start_task(task_id: NewType.<locals>.new_type) → 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: NewType.<locals>.new_type) → None[source]

Stop a task.

This will freeze the elapsed time on the task.

Parameters

task_id (TaskID) – ID of task.

property task_ids

A list of task IDs.

property tasks

Get a list of Task instances.

track(sequence: Union[Iterable[ProgressType], Sequence[ProgressType]], total: int = None, task_id: Optional[NewType.<locals>.new_type] = None, description='Working...', update_period: float = 0.1) → Iterable[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 – (int, 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: NewType.<locals>.new_type, *, total: float = None, completed: float = None, advance: float = None, description: str = None, visible: 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[source]

Base class for a widget to use in progress display.

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.Task(id: NewType.<locals>.new_type, description: str, total: float, completed: float, _get_time: Callable[[], float], visible: bool = True, fields: Dict[str, Any] = <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

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

Check if the task has completed.

Type

bool

get_time() → float[source]

float: Get the current time, in seconds.

id: NewType.<locals>.new_type

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

property percentage

Get progress of task as a percentage.

Type

float

property remaining

Get the number of steps remaining.

Type

float

property speed

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

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

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: rich.highlighter.Highlighter = None)[source]

A column containing text.

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

Should return a renderable object.

class rich.progress.TimeRemainingColumn[source]

Renders estimated time remaining.

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

Show time remaining.

class rich.progress.TotalFileSizeColumn[source]

Renders total filesize.

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

Show data completed.

class rich.progress.TransferSpeedColumn[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[ProgressType], Iterable[ProgressType]], description='Working...', total: int = None, auto_refresh=True, console: Optional[rich.console.Console] = None, transient: bool = False, get_time: Callable[], float] = None, refresh_per_second: int = None, 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) → Iterable[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 – (int, 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 (Optional[int], optional) – Number of times per second to refresh the progress information, or None to use default. Defaults to None.

  • 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.

Returns

An iterable of the values in the sequence.

Return type

Iterable[ProgressType]