Progress Tracker

class pathsim.utils.progresstracker.ProgressTracker(total_duration, description='Progress', logger=None, log=True, log_level=20, min_log_interval=1.0, update_log_every=0.2, bar_width=20, ema_alpha=0.3)[source]

Bases: object

A progress tracker for simulations with adaptive ETA and step rate display.

Uses exponential moving average for stable rate estimates and smart ETA calculation. Can be used as both an iterator and a context manager.

Parameters:
  • total_duration (float) – The total simulation duration to track against. Must be positive.

  • description (str, optional) – Description for log messages. Defaults to “Progress”.

  • logger (logging.Logger, optional) – Logger instance. If None, uses LoggerManager. Defaults to None.

  • log (bool, optional) – Enable logging. Defaults to True.

  • log_level (int, optional) – Logging level. Defaults to logging.INFO.

  • min_log_interval (float, optional) – Minimum seconds between logs. Defaults to LOG_MIN_INTERVAL.

  • update_log_every (float, optional) – Log every N progress fraction (e.g., 0.2 = 20%). Defaults to LOG_UPDATE_EVERY.

  • bar_width (int, optional) – Progress bar width in characters. Defaults to 20.

  • ema_alpha (float, optional) – EMA smoothing factor (0-1), lower = more smoothing. Defaults to 0.3.

property current_progress

Current progress fraction (0.0 to 1.0)

start()[source]

Start the progress tracker

update(progress, success=True, **kwargs)[source]

Update progress and optionally log

Parameters:
  • progress (float) – Progress fraction (0.0 to 1.0)

  • success (bool, optional) – Whether this step was successful. Defaults to True.

  • **kwargs – Additional data (first key-value shown in logs if provided)

interrupt()[source]

Mark tracker as interrupted

close()[source]

Close tracker and log final stats