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:
objectA 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.
- 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:
objectController of progress bars showing how far each algorithm has progressed and the estimated time remaining.
- Parameters:
manager – A multiprocessing
SyncManagerinstance 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. IfNone, 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.