decent_bench.utils.progress_bar#

class decent_bench.utils.progress_bar.ProgressBarHandle(_progress_increment_queue: Queue[Any], _progress_bar_ids: dict[Algorithm[Any], int], _progress_step: int | None)[source]#

Bases: object

A picklable handle for worker processes to update ProgressBarController.

This class contains only the picklable parts needed by worker processes, separating them from the unpicklable Thread components in ProgressBarController.

start_progress_bar(algorithm: Algorithm[Any], trial: int, initial_progress: int) None[source]#

Start the clock of algorithm’s progress bar without incrementing it.

Internally, this is done through sending an increment of 0 to the progress listener. The progress listener recognizes that the algorithm’s execution just started and resets its clock, which started when the progress bar was first rendered.

advance_progress_bar(algorithm: Algorithm[Any], iteration: int) None[source]#

Advance algorithm’s progress bar by an amount (units).

class decent_bench.utils.progress_bar.ProgressBarController(manager: SyncManager | None, algorithms: Sequence[Algorithm[Any]], n_trials: int, progress_step: int | None, show_speed: bool = False, show_trial: bool = False)[source]#

Bases: object

Controller of progress bars showing how far each algorithm has progressed and the estimated time remaining.

Parameters:
  • manager – A multiprocessing SyncManager instance used to create a shared queue for coordinating progress updates across multiple processes. This enables thread-safe communication between worker processes and the progress bar listener thread. If None, a local in-process queue is used.

  • algorithms – algorithms that will be run, each gets its own bar

  • n_trials – number of trials the algorithms will run

  • progress_step – if provided, the progress bar will step every progress_step. When provided, each algorithm’s task total becomes n_trials * ceil(algorithm.iterations / progress_step). If None, the progress bar uses 1 unit per trial.

Note

If progress_step is too small performance may degrade due to the overhead of updating the progress bar too often.

mark_one_trial_as_complete(algorithm: Algorithm[Any], trial: int) None[source]#

Mark a trial of algorithm as complete in the progress bar.

get_handle() ProgressBarHandle[source]#

Get a picklable handle for worker processes.

Returns a handle containing only the queue and metadata needed by worker processes, without the unpicklable Thread component.

stop() None[source]#

Stop the progress bar and wait for the listener thread to finish.