Progress tracker with stages and ETA estimation. Stages: 1. Dependency Analysis (40% of time) 2. Module Clustering (20% of time) 3. Documentation Generation (30% of time) 4. HTML Generation (5% of time, optional) 5. Finalization (5% of time)
| 9 | |
| 10 | |
| 11 | class ProgressTracker: |
| 12 | """ |
| 13 | Progress tracker with stages and ETA estimation. |
| 14 | |
| 15 | Stages: |
| 16 | 1. Dependency Analysis (40% of time) |
| 17 | 2. Module Clustering (20% of time) |
| 18 | 3. Documentation Generation (30% of time) |
| 19 | 4. HTML Generation (5% of time, optional) |
| 20 | 5. Finalization (5% of time) |
| 21 | """ |
| 22 | |
| 23 | # Stage weights (percentage of total time) |
| 24 | STAGE_WEIGHTS = { |
| 25 | 1: 0.40, # Dependency Analysis |
| 26 | 2: 0.20, # Module Clustering |
| 27 | 3: 0.30, # Documentation Generation |
| 28 | 4: 0.05, # HTML Generation (optional) |
| 29 | 5: 0.05, # Finalization |
| 30 | } |
| 31 | |
| 32 | STAGE_NAMES = { |
| 33 | 1: "Dependency Analysis", |
| 34 | 2: "Module Clustering", |
| 35 | 3: "Documentation Generation", |
| 36 | 4: "HTML Generation", |
| 37 | 5: "Finalization", |
| 38 | } |
| 39 | |
| 40 | def __init__(self, total_stages: int = 5, verbose: bool = False): |
| 41 | """ |
| 42 | Initialize progress tracker. |
| 43 | |
| 44 | Args: |
| 45 | total_stages: Number of stages |
| 46 | verbose: Enable verbose output |
| 47 | """ |
| 48 | self.total_stages = total_stages |
| 49 | self.current_stage = 0 |
| 50 | self.stage_progress = 0.0 |
| 51 | self.start_time = time.time() |
| 52 | self.verbose = verbose |
| 53 | self.current_stage_start = self.start_time |
| 54 | |
| 55 | def start_stage(self, stage: int, description: Optional[str] = None): |
| 56 | """ |
| 57 | Start a new stage. |
| 58 | |
| 59 | Args: |
| 60 | stage: Stage number (1-5) |
| 61 | description: Optional custom description |
| 62 | """ |
| 63 | self.current_stage = stage |
| 64 | self.stage_progress = 0.0 |
| 65 | self.current_stage_start = time.time() |
| 66 | |
| 67 | stage_name = description or self.STAGE_NAMES.get(stage, f"Stage {stage}") |
| 68 |