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.

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.

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.

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: int | float | 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: