Represents a documentation generation job. Attributes: job_id: Unique job identifier repository_path: Absolute path to repository repository_name: Repository name output_directory: Output directory path commit_hash: Git commit SHA branch_
| 46 | |
| 47 | @dataclass |
| 48 | class DocumentationJob: |
| 49 | """ |
| 50 | Represents a documentation generation job. |
| 51 | |
| 52 | Attributes: |
| 53 | job_id: Unique job identifier |
| 54 | repository_path: Absolute path to repository |
| 55 | repository_name: Repository name |
| 56 | output_directory: Output directory path |
| 57 | commit_hash: Git commit SHA |
| 58 | branch_name: Git branch name (if applicable) |
| 59 | timestamp_start: Job start time |
| 60 | timestamp_end: Job end time (if completed) |
| 61 | status: Current job status |
| 62 | error_message: Error message (if failed) |
| 63 | files_generated: List of generated files |
| 64 | module_count: Number of modules documented |
| 65 | generation_options: Generation options used |
| 66 | llm_config: LLM configuration used |
| 67 | statistics: Job statistics |
| 68 | """ |
| 69 | job_id: str = field(default_factory=lambda: str(uuid.uuid4())) |
| 70 | repository_path: str = "" |
| 71 | repository_name: str = "" |
| 72 | output_directory: str = "" |
| 73 | commit_hash: str = "" |
| 74 | branch_name: Optional[str] = None |
| 75 | timestamp_start: str = field(default_factory=lambda: datetime.now().isoformat()) |
| 76 | timestamp_end: Optional[str] = None |
| 77 | status: JobStatus = JobStatus.PENDING |
| 78 | error_message: Optional[str] = None |
| 79 | files_generated: List[str] = field(default_factory=list) |
| 80 | module_count: int = 0 |
| 81 | generation_options: GenerationOptions = field(default_factory=GenerationOptions) |
| 82 | llm_config: Optional[LLMConfig] = None |
| 83 | statistics: JobStatistics = field(default_factory=JobStatistics) |
| 84 | |
| 85 | def start(self): |
| 86 | """Mark job as started.""" |
| 87 | self.status = JobStatus.RUNNING |
| 88 | self.timestamp_start = datetime.now().isoformat() |
| 89 | |
| 90 | def complete(self): |
| 91 | """Mark job as completed.""" |
| 92 | self.status = JobStatus.COMPLETED |
| 93 | self.timestamp_end = datetime.now().isoformat() |
| 94 | |
| 95 | def fail(self, error_message: str): |
| 96 | """Mark job as failed.""" |
| 97 | self.status = JobStatus.FAILED |
| 98 | self.error_message = error_message |
| 99 | self.timestamp_end = datetime.now().isoformat() |
| 100 | |
| 101 | def to_dict(self) -> Dict[str, Any]: |
| 102 | """Convert to dictionary for JSON serialization.""" |
| 103 | data = { |
| 104 | "job_id": self.job_id, |
| 105 | "repository_path": self.repository_path, |