mafw.ui.rich_user_interface

The rich user interface.

The module provides an implementation of the abstract user interface that takes advantage from the rich library. Progress bars and spinners are shown during the processor execution along with log messages including markup language. In order for this logging message to appear properly rendered, the logger should be connected to a RichHandler.

Classes

RichInterface([progress_kws])

Implementation of the interface for rich.

class mafw.ui.rich_user_interface.RichInterface(progress_kws: dict[str, Any] | None = None)[source]

Bases: UserInterfaceBase

Implementation of the interface for rich.

Parameters:

progress_kws (dict, Optional) – A dictionary of keywords passed to the rich.Progress. Defaults to None

create_task(task_name: str, task_description: str = '', completed: int = 0, increment: int | None = None, total: int | None = None, **kwargs: Any) None[source]

Create a new task.

Parameters:
  • task_name (str) – A unique identifier for the task. You cannot have more than 1 task with the same name in the whole execution. If you want to use the processor name, it is recommended to use the unique_name.

  • task_description (str, Optional) – A short description for the task. Defaults to ‘’.

  • completed (int, Optional) – The amount of task already completed. Defaults to 0.

  • increment (int, Optional) – How much of the task has been done since last update. Defaults to None.

  • total (int, Optional) – The total amount of task. Defaults to None.

display_progress_message(message: str, i_item: int, n_item: int | None, frequency: float) None[source]

Display a message during the process execution.

Parameters:
  • message (str) – The message to be displayed.

  • i_item (int) – The current item enumerator.

  • n_item (int | None) – The total number of items or None for an indeterminate progress (while loop).

  • frequency (float) – How often (in percentage of n_item) to display the message.

update_task(task_name: str, completed: int = 0, increment: int | None = None, total: int | None = None, **kwargs: Any) None[source]

Update an existing task.

Parameters:
  • task_name (str) – A unique identifier for the task. You cannot have more than one task with the same name in the whole execution. If you want to use the processor name, it is recommended to use the unique_name.

  • completed (int, Optional) – The amount of task already completed. Defaults to 0.

  • increment (int, Optional) – How much of the task has been done since last update. Defaults to None.

  • total (int, Optional) – The total amount of task. Defaults to None.

name = 'rich'

The name of the interface