feat(gui): 全流程面板合并 + 一键式运行 GUI 入口集成
This commit is contained in:
@ -8,7 +8,17 @@ Pipeline 调度核心:基于 Context 的内存级依赖注入。
|
||||
- 不绑定具体 Pipeline 实现(duck-typed),WorkerThread / Web API / 单测可共用
|
||||
"""
|
||||
|
||||
from .context import PipelineContext
|
||||
from .runner import StepSpec, PIPELINE_STEPS, PipelineRunner
|
||||
from .context import (
|
||||
PipelineContext,
|
||||
STEP_MAP_OLD_TO_NEW, STEP_MAP_NEW_TO_OLD,
|
||||
resolve_step_id, ALL_STEP_IDS,
|
||||
)
|
||||
from .runner import (
|
||||
StepSpec, PIPELINE_STEPS, PipelineRunner, PipelineHalt,
|
||||
)
|
||||
|
||||
__all__ = ["PipelineContext", "StepSpec", "PIPELINE_STEPS", "PipelineRunner"]
|
||||
__all__ = [
|
||||
"PipelineContext", "StepSpec", "PIPELINE_STEPS", "PipelineRunner", "PipelineHalt",
|
||||
"STEP_MAP_OLD_TO_NEW", "STEP_MAP_NEW_TO_OLD",
|
||||
"resolve_step_id", "ALL_STEP_IDS",
|
||||
]
|
||||
|
||||
@ -12,7 +12,34 @@ PipelineContext:内存级数据载体,跨 14 个 step 传递路径与元信
|
||||
|
||||
from __future__ import annotations
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Any, Dict, List, Optional
|
||||
from typing import Any, Dict, List, Optional, Set
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 步骤命名映射(定义在叶子节点,打破循环依赖)
|
||||
# ============================================================
|
||||
|
||||
STEP_MAP_OLD_TO_NEW: Dict[str, str] = {
|
||||
"step5_5": "step8",
|
||||
"step6_5": "step8_non_empirical_modeling",
|
||||
"step6_75": "step9",
|
||||
"step8_5": "step11",
|
||||
"step8_75": "step12",
|
||||
"step7": "step10",
|
||||
"step8": "step11_ml",
|
||||
"step9": "step14",
|
||||
}
|
||||
|
||||
STEP_MAP_NEW_TO_OLD: Dict[str, str] = {v: k for k, v in STEP_MAP_OLD_TO_NEW.items()}
|
||||
|
||||
ALL_STEP_IDS: Set[str] = set(STEP_MAP_OLD_TO_NEW.keys()) | set(STEP_MAP_OLD_TO_NEW.values())
|
||||
|
||||
|
||||
def resolve_step_id(step_id: str) -> str:
|
||||
"""将任意 step_id 转换为标准新格式。"""
|
||||
if step_id in STEP_MAP_OLD_TO_NEW:
|
||||
return STEP_MAP_OLD_TO_NEW[step_id]
|
||||
return step_id
|
||||
|
||||
|
||||
@dataclass
|
||||
@ -63,10 +90,29 @@ class PipelineContext:
|
||||
pipeline_end_time: Optional[float] = None
|
||||
last_error: Optional[str] = None
|
||||
|
||||
# ── 错误汇总(全流程结束后可用) ──
|
||||
error_summary: List[tuple[str, str]] = field(default_factory=list)
|
||||
# ── 出错时立即停止全流程(默认 False:继续后续步骤) ──
|
||||
breakpoint_on_error: bool = False
|
||||
# ── ★ 智能补全锁定步骤列表(由 _auto_fill_missing_steps 自动开启的步骤) ──
|
||||
# GUI 层读取此字段,在运行期间禁用对应面板的启用复选框
|
||||
locked_steps: List[str] = field(default_factory=list)
|
||||
|
||||
# ============================================================
|
||||
# 读写辅助
|
||||
# ============================================================
|
||||
|
||||
def step_id(self, step_id: str) -> str:
|
||||
"""将任意 step_id(可能是旧名)转换为标准新格式。
|
||||
|
||||
用法示例:
|
||||
ctx.status[ctx.step_id('step6_5')] # 'step8_non_empirical_modeling'
|
||||
ctx.user_config[ctx.step_id('step8_5')] # 'step11'
|
||||
"""
|
||||
if step_id in STEP_MAP_OLD_TO_NEW:
|
||||
return STEP_MAP_OLD_TO_NEW[step_id]
|
||||
return step_id
|
||||
|
||||
def set(self, key: str, value: Any) -> None:
|
||||
"""原地写入任意属性。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user