Spaces:
Runtime error
Runtime error
| import time | |
| import json | |
| from pathlib import Path | |
| def load_messages() -> list: | |
| """Load status messages from JSON file.""" | |
| with open('loading_messages.json', 'r') as f: | |
| return json.load(f)['messages'] | |
| class StatusTracker: | |
| """ | |
| Track and display progress status for video generation. | |
| """ | |
| def __init__(self, progress, status_box=None): | |
| self.progress = progress | |
| self.status_box = status_box | |
| self.steps = [] | |
| self.current_message = "" | |
| self._status_markdown = "" | |
| def add_step(self, message: str, progress_value: float): | |
| """ | |
| Add a permanent step to the progress display. | |
| Args: | |
| message: Step description | |
| progress_value: Progress value between 0 and 1 | |
| """ | |
| self.steps.append(message) | |
| self._update_display(progress_value) | |
| def update_message(self, message: str, progress_value: float): | |
| """ | |
| Update the current working message. | |
| Args: | |
| message: Current status message | |
| progress_value: Progress value between 0 and 1 | |
| """ | |
| self.current_message = message | |
| self._update_display(progress_value) | |
| def _update_display(self, progress_value: float): | |
| """ | |
| Update the status display with current progress. | |
| Args: | |
| progress_value: Progress value between 0 and 1 | |
| """ | |
| # Create status display | |
| status_md = "### 🎬 Generation Progress\n\n" | |
| # Show completed steps | |
| if self.steps: | |
| for step in self.steps: | |
| status_md += f"✓ {step}\n" | |
| status_md += "\n" | |
| # Show current message prominently | |
| if self.current_message: | |
| status_md += f"### 🔄 {self.current_message}\n" | |
| self._status_markdown = status_md | |
| self.progress(progress_value) | |
| # Update status box if it exists | |
| if self.status_box is not None: | |
| try: | |
| self.status_box.update(value=self._status_markdown) | |
| except: | |
| pass # Silently handle if update fails | |
| def get_status(self) -> str: | |
| """Get the current status markdown.""" | |
| return self._status_markdown | |