simplebench.tasks moduleπŸ”—

module for managing progress tasks using Rich Progress.

class simplebench.tasks.ProgressTracker(
*,
session: Session | None = None,
task_name: str,
progress_max: int | float = 100,
description: str = 'Benchmarking',
color: Color = Color.GREEN,
)[source]πŸ”—

Bases: object

Helper to manage benchmark progress updates.

Initialize the ProgressTracker.

Parameters:
  • session (Session or None) – The Session instance.

  • task_name (str) – The name of the progress task.

  • progress_max (int or float, optional) – The maximum value for progress completion. Defaults to 100.

  • description (str, optional) – The description for the progress task. Defaults to β€˜Benchmarking’.

  • color (Color, optional) – The color for the progress task. Defaults to GREEN.

property is_running: boolπŸ”—

Check if the Rich Progress display is currently running.

Returns:

True if the display is running, False otherwise.

Return type:

bool

refresh() None[source]πŸ”—

Refresh the progress tracking display.

reset(start: bool = True) None[source]πŸ”—

Reset the progress tracking.

This will reset the progress completion to zero and start it running by default.

Parameters:

start (bool, optional) – Whether to start the progress tracking after resetting. Defaults to True.

start() None[source]πŸ”—

Start the progress tracking.

stop() None[source]πŸ”—

Stop the progress tracking.

property styled_description: strπŸ”—

Get the styled description for the progress task.

update(
completed: int | float,
description: str,
refresh: bool | None = None,
color: Color | None = None,
) None[source]πŸ”—

Update progress display.

class simplebench.tasks.RichProgressTasks(
verbosity: Verbosity,
console: Console | None = None,
)[source]πŸ”—

Bases: object

Task Rich Progress management for benchmarking.

Initialize a new RichProgressTasks instance.

This instance manages multiple RichTask instances and provides a Rich Progress display for console output.

The display will not start until the start() method is called on this instance.

Parameters:
  • verbosity (Verbosity) – The verbosity level for console output.

  • console (Console, optional) – The Rich Console instance for displaying output. If None, a new Console will be created as needed. Defaults to None.

Raises:

SimpleBenchTypeError – If verbosity is not a Verbosity enum.

add_task(
name: str,
description: str,
total: float = 100.0,
) RichTask[source]πŸ”—

Add a new task to the Rich Progress display.

If a task with the same name already exists, a SimpleBenchValueError is raised.

Parameters:
  • name (str) – The unique name for the task.

  • description (str) – The description to display for the task.

  • total (float) – The total number of steps for the task. Defaults to 100.0.

Raises:

SimpleBenchValueError – If a task with the same name already exists.

Returns:

The newly created RichTask instance.

Return type:

RichTask

clear() None[source]πŸ”—

Clear all tasks from the internal task management.

This causes all tasks to be terminated and removed from the managed index.

get(
name: str,
) RichTask | None[source]πŸ”—

Get a task by name or return None if not found.

Parameters:

name (str) – The name of the task to retrieve.

Returns:

The requested task, or None if not found.

Return type:

RichTask or None

property is_running: boolπŸ”—

If the Rich Progress display is currently running.

The display is considered running if the start() method has been called and the stop() method has not yet been called.

Value is True if running, False otherwise.

new_task(
name: str,
description: str,
total: float = 0,
completed: int = 0,
) RichTask[source]πŸ”—

Create a new RichTask.

The new task is initialized with the given parameters, added to the task manager index, and a RichTask instance returned.

The RichTask instance provides control over the task’s progress and status.

Parameters:
  • name (str) – The name of the task.

  • description (str) – The description of the task.

  • total (int) – The total number of steps for the task.

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

Returns:

The created RichTask instance.

Return type:

RichTask

property progress: ProgressπŸ”—

Get the Rich Progress instance.

start() None[source]πŸ”—

Start the Rich Progress display.

stop() None[source]πŸ”—

Stop the Rich Progress display.

class simplebench.tasks.RichTask(
progress: Progress,
name: str,
description: str,
completed: int = 0,
total: float = 100.0,
verbosity: Verbosity = Verbosity.NORMAL,
)[source]πŸ”—

Bases: object

Represents and controls a Rich Progress task.

Construct a new RichTask.

Parameters:
  • name (str) – The name of the task.

  • description (str) – The description of the task.

  • completed (int, optional) – Completion step. Defaults to 0.

  • total (int, optional) – Total number of steps. Defaults to 100.

  • progress (Progress) – The Progress instance to use.

  • verbosity (Verbosity) – The verbosity level for console output.

Raises:
get_task() Task | None[source]πŸ”—

Get the Rich Task instance from the Progress instance.

Returns:

The Rich Task instance, or None if not found.

Return type:

Task or None

refresh() None[source]πŸ”—

Refresh the task progress display.

reset(start: bool = True) None[source]πŸ”—

Reset the task progress.

start() None[source]πŸ”—

Start the task.

stop() None[source]πŸ”—

Stop the task.

terminate_and_remove() None[source]πŸ”—

Terminate the task and remove it from the progress display.

update(
completed: float | int | None = None,
description: str | None = None,
refresh: bool | None = None,
) None[source]πŸ”—

Update the task progress.

If an attempt to update a terminated task is made, a SimpleBenchRuntimeError will be raised.

Parameters:
  • completed (int or float, optional) – The number of completed steps.

  • description (str, optional) – The description of the task.

  • refresh (bool, optional) – Whether to refresh the progress display.

Raises: