节点信息
| 10 | from typing import Dict, List, Set, Optional, Tuple |
| 11 | |
| 12 | class NodeInfo: |
| 13 | """节点信息""" |
| 14 | def __init__(self, node_id: str, stage: str, parent_id: Optional[str] = None): |
| 15 | self.id = node_id |
| 16 | self.stage = stage # root, draft, improve, debug |
| 17 | self.parent_id = parent_id |
| 18 | self.children_ids: List[str] = [] |
| 19 | self.metric: Optional[float] = None |
| 20 | self.is_terminal: bool = False |
| 21 | self.is_buggy: bool = False |
| 22 | self.continue_improve: bool = False |
| 23 | self.improve_failure: Optional[int] = None # 记录失败次数 |
| 24 | self.run_status: str = "unknown" # OK, FAIL, unknown |
| 25 | |
| 26 | def __str__(self): |
| 27 | status_sym = "✓" if self.run_status == "OK" else "✗" if self.run_status == "FAIL" else "?" |
| 28 | metric_str = f" m:{self.metric:.4f}" if self.metric else "" |
| 29 | terminal_str = " [T]" if self.is_terminal else "" |
| 30 | return f"{status_sym} {self.stage[:1]}{self.id[:8]}{metric_str}{terminal_str}" |
| 31 | |
| 32 | |
| 33 | def parse_log(log_file: str) -> Tuple[Dict[str, NodeInfo], str]: |