fix(runner): step5 严格依赖 step4 产物 + 拒绝静默跳过
- step5.requires 加入 processed_csv_path(step4 产物) 并显式 parameter_map 到 csv_path 形参;step5.skip_when_missing=False 配合 Facade **kwargs 兜底 - parameter_map 双向映射规避 L2 顺序注入冲突: processed_csv_path→csv_path(主), csv_path→_raw_csv_ignored(占位, 落 **kwargs) - PipelineRunner.run() skip_when_missing 块新增 _notify 通知, 让 GUI 知道具体缺了什么(拒绝静默跳过)
This commit is contained in:
@ -67,8 +67,18 @@ PIPELINE_STEPS: List[StepSpec] = [
|
|||||||
),
|
),
|
||||||
StepSpec(
|
StepSpec(
|
||||||
step_id="step5", method_name="step5_extract_training_spectra",
|
step_id="step5", method_name="step5_extract_training_spectra",
|
||||||
requires=["deglint_img_path", "csv_path", "boundary_path", "glint_mask_path"],
|
requires=["deglint_img_path", "processed_csv_path", "csv_path", "boundary_path", "glint_mask_path"],
|
||||||
produces=["training_csv_path"],
|
produces=["training_csv_path"],
|
||||||
|
# processed_csv_path(step4 产物) 才是 step5 真正需要的主路径,
|
||||||
|
# 通过 parameter_map 显式映射到形参 csv_path。
|
||||||
|
# raw csv_path 也保留在 requires 中以备 user_config 覆盖,
|
||||||
|
# 但用占位名 _raw_csv_ignored 注入,落到 step5 形参列表末尾的 **kwargs 兜底。
|
||||||
|
# 这样可以避免 L2 顺序注入中"后注入的 csv_path=None 覆盖前面的 processed_csv_path"的冲突。
|
||||||
|
parameter_map={
|
||||||
|
"processed_csv_path": "csv_path",
|
||||||
|
"csv_path": "_raw_csv_ignored",
|
||||||
|
},
|
||||||
|
skip_when_missing=False,
|
||||||
description="实测样本点光谱提取",
|
description="实测样本点光谱提取",
|
||||||
),
|
),
|
||||||
StepSpec(
|
StepSpec(
|
||||||
@ -157,9 +167,10 @@ class PipelineRunner:
|
|||||||
missing = [k for k in spec.requires if not ctx.get(k)]
|
missing = [k for k in spec.requires if not ctx.get(k)]
|
||||||
if missing:
|
if missing:
|
||||||
ctx.status[spec.step_id] = "skipped"
|
ctx.status[spec.step_id] = "skipped"
|
||||||
ctx.append_log(
|
reason = f"缺少必要的上下文参数,自动跳过: {missing}"
|
||||||
f"[RUNNER] {spec.step_id} 缺少入参: {missing},跳过"
|
ctx.append_log(f"[RUNNER] {spec.step_id} {reason}")
|
||||||
)
|
if hasattr(self.pipeline, "_notify"):
|
||||||
|
self.pipeline._notify(spec.description, "skipped", reason)
|
||||||
continue
|
continue
|
||||||
self._invoke(spec, ctx)
|
self._invoke(spec, ctx)
|
||||||
ctx.pipeline_end_time = time.time()
|
ctx.pipeline_end_time = time.time()
|
||||||
|
|||||||
Reference in New Issue
Block a user