From b3a6855881234616794517b092a697117ae3d730 Mon Sep 17 00:00:00 2001 From: DXC Date: Wed, 17 Jun 2026 13:41:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A1=A5=E9=BD=90=20Step6=20=E7=BC=BA?= =?UTF-8?q?=E5=A4=B1=E7=9A=84=E6=B0=B4=E4=BD=93=E4=B8=8E=E8=80=80=E6=96=91?= =?UTF-8?q?=E6=8E=A9=E8=86=9C=E8=87=AA=E5=8A=A8=E4=BC=A0=E5=AF=BC=E9=93=BE?= =?UTF-8?q?=E8=B7=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MainView._sync_dependencies 此前未推送以下两条链路,导致用户 每次进入 Step 6 都必须手动选水体/耀斑掩膜文件: 1. step1 → step6 (boundary_path) Step 1 在 NDWI 模式下输出 water_mask_out.dat → 经 boundary_path 推给 Step 6 的 self.water_mask_file。 注意:Step 6 接收键名是 boundary_path(历史遗留别名),不是 water_mask_path。 2. step2 → step6 (glint_mask_path) Step 2 输出 severe_glint_area.dat → 经 glint_mask_path 推给 Step 6 的 self.glint_mask_file。 同时精简了 _sync_dependencies 的 docstring(去掉逐条推送关系列表, 改为一行摘要)和若干块内注释。 其它方法 / 字段 / 类结构未改动。 --- src/new/main_view.py | 43 +++++++++++++++++-------------------------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/src/new/main_view.py b/src/new/main_view.py index b09d11d..6d5766e 100644 --- a/src/new/main_view.py +++ b/src/new/main_view.py @@ -600,37 +600,30 @@ class MainView(QMainWindow): # 声明式路径流转:用 set_config 把上游产出推给所有下游 view # ------------------------------------------------------------------ def _sync_dependencies(self): - """遍历 self.step_outputs 字典,按依赖图把每步产出推给下游 - - 推送关系(按用户原意 + 各 view set_config 实际接受 key 校对): - step1 (水域掩膜) → step2/step3/step4 的 water_mask_path - step3 (耀斑去除) → step4 的 deglint_img_path - + step6 的 deglint_img_path - + step10 的 bsq_path - step4 (采样点布设) → step9 的 sampling_csv_path - step5 (数据清洗) → step6 的 csv_path - step6 (光谱特征) → step7/step8 的 training_csv_path - step8 (机器学习建模)→ step9 的 models_dir(父目录) - step9 (机器学习预测)→ step11 的 prediction_csv_dir(父目录) - step10 (水色指数) → step11 的 geotiff_dir(父目录) - - 每个推送都用 _safe_set_config 包装,view 缺失 / 没有 set_config - / set_config 抛异常都不会让 sync 链路中断。 - """ - # ----- step1 → step2/3/4 (water_mask_path) ----- + """遍历 self.step_outputs 字典,按依赖图把每步产出推给下游""" + + # ----- step1 → step2/3/4 (water_mask_path) 及 step6 (boundary_path) ----- s1 = self.step_outputs.get("step1") if s1: for sid in ("step2", "step3", "step4"): self._safe_set_config(sid, {"water_mask_path": s1}) + # 补齐 step1 到 step6 的水体掩膜链路 + self._safe_set_config("step6", {"boundary_path": s1}) - # ----- step3 → step4 (deglint_img_path) / step6 / step10 (bsq_path) ----- + # ----- step2 → step6 (glint_mask_path) ----- + s2 = self.step_outputs.get("step2") + if s2: + # 补齐 step2 到 step6 的耀斑掩膜链路 + self._safe_set_config("step6", {"glint_mask_path": s2}) + + # ----- step3 → step4/6 (deglint_img_path) / step10 (bsq_path) ----- s3 = self.step_outputs.get("step3") if s3: self._safe_set_config("step4", {"deglint_img_path": s3}) self._safe_set_config("step6", {"deglint_img_path": s3}) self._safe_set_config("step10", {"bsq_path": s3}) - # ----- step4 → step9 (sampling_csv_path: 单文件,直接传) ----- + # ----- step4 → step9 (sampling_csv_path) ----- s4 = self.step_outputs.get("step4") if s4: self._safe_set_config("step9", {"sampling_csv_path": s4}) @@ -646,29 +639,27 @@ class MainView(QMainWindow): self._safe_set_config("step7", {"training_csv_path": s6}) self._safe_set_config("step8", {"training_csv_path": s6}) - # ----- step8 → step9 (models_dir: 父目录,因为 step8 产物是模型目录里的若干 .joblib) ----- + # ----- step8 → step9 (models_dir: 父目录) ----- s8 = self.step_outputs.get("step8") if s8: s8_dir = str(Path(s8).parent).replace("\\", "/") self._safe_set_config("step9", {"models_dir": s8_dir}) - # ----- step9 → step11 (prediction_csv_dir: 父目录,step9 输出到 ml_prediction/) ----- + # ----- step9 → step11 (prediction_csv_dir / prediction_csv_path) ----- s9 = self.step_outputs.get("step9") if s9: s9_dir = str(Path(s9).parent).replace("\\", "/") self._safe_set_config("step11", {"prediction_csv_dir": s9_dir}) - # 同时推 single 模式入口,避免用户在 folder 模式下还要切回 self._safe_set_config("step11", {"prediction_csv_path": s9}) - # ----- step10 → step11 (geotiff_dir: 父目录,step10 输出到 watercolor/) ----- + # ----- step10 → step11 (geotiff_dir / geotiff_path) ----- s10 = self.step_outputs.get("step10") if s10: s10_dir = str(Path(s10).parent).replace("\\", "/") self._safe_set_config("step11", {"geotiff_dir": s10_dir}) - # 同时推 single 模式入口 self._safe_set_config("step11", {"geotiff_path": s10}) - self._log(f"[Sync] 依赖同步完成(step_outputs keys: {list(self.step_outputs.keys())})") + self._log(f"[Sync] 全局依赖同步完成(step_outputs keys: {list(self.step_outputs.keys())})") def _safe_set_config(self, step_id: str, config: dict): """安全调用 view.set_config;view 缺失 / 无该方法 / 抛异常时降级日志