fix(step12_viz): scatter 模型目录改读 self.extra + 主线程 step8 预取注入
worker generate_all_selected.gen_scatter 块改读 self.extra['models_dir'],
fallback 到 wp / 8_Supervised_Model_Training(替换旧版 7_Supervised_Model_Training)。
主线程 generate_all_visualizations 通过 panel_factory.get_panel('step8_ml_train')
预取 step8 panel.output_path,注入 extra 字典 models_dir 键。
Why: 子线程内 self.window() 无意义(VisualizationWorkerThread 是 QThread 子类
且无 parent 传参),必须主线程预取 + worker 读 extra 字典。与同文件既有
scatter 任务(line 208-209)和 step11 风格统一。
This commit is contained in:
@ -223,11 +223,19 @@ class VisualizationWorkerThread(QThread):
|
|||||||
viz = WaterQualityVisualization(output_dir=str(resolve_subdir(self.work_dir, 'visualization')))
|
viz = WaterQualityVisualization(output_dir=str(resolve_subdir(self.work_dir, 'visualization')))
|
||||||
parts = []
|
parts = []
|
||||||
|
|
||||||
|
training_csv_path = (self.extra.get("training_csv_path") or "").strip()
|
||||||
|
if training_csv_path:
|
||||||
|
training_csv = Path(training_csv_path)
|
||||||
|
else:
|
||||||
training_csv = wp / "5_training_spectra" / "training_spectra.csv"
|
training_csv = wp / "5_training_spectra" / "training_spectra.csv"
|
||||||
|
|
||||||
if self.extra.get("gen_scatter"):
|
if self.extra.get("gen_scatter"):
|
||||||
if training_csv.is_file():
|
if training_csv.is_file():
|
||||||
models_dir = wp / "7_Supervised_Model_Training"
|
models_dir_str = (self.extra.get("models_dir") or "").strip()
|
||||||
|
if models_dir_str:
|
||||||
|
models_dir = Path(models_dir_str)
|
||||||
|
else:
|
||||||
|
models_dir = wp / "8_Supervised_Model_Training"
|
||||||
if models_dir.is_dir() and any(d.is_dir() for d in models_dir.iterdir()):
|
if models_dir.is_dir() and any(d.is_dir() for d in models_dir.iterdir()):
|
||||||
from src.core.visualization.scatter_plot import generate_model_scatter_plots
|
from src.core.visualization.scatter_plot import generate_model_scatter_plots
|
||||||
scatter_paths = generate_model_scatter_plots(
|
scatter_paths = generate_model_scatter_plots(
|
||||||
@ -1672,6 +1680,18 @@ class Step12VizPanel(QWidget):
|
|||||||
"gen_mask_glint": self.gen_mask_glint.isChecked(),
|
"gen_mask_glint": self.gen_mask_glint.isChecked(),
|
||||||
"gen_sampling_map": self.gen_sampling_map.isChecked(),
|
"gen_sampling_map": self.gen_sampling_map.isChecked(),
|
||||||
}
|
}
|
||||||
|
main_window = self.window()
|
||||||
|
factory = getattr(main_window, '_panel_factory', None) if main_window else None
|
||||||
|
step5_panel = factory.get_panel('step5_clean') if factory else None
|
||||||
|
if step5_panel and getattr(step5_panel, 'output_file', None):
|
||||||
|
_resolved_csv = step5_panel.output_file.get_path()
|
||||||
|
if _resolved_csv:
|
||||||
|
extra["training_csv_path"] = _resolved_csv
|
||||||
|
step8_panel = factory.get_panel('step8_ml_train') if factory else None
|
||||||
|
if step8_panel and getattr(step8_panel, 'output_path', None):
|
||||||
|
_resolved_models_dir = step8_panel.output_path.get_path()
|
||||||
|
if _resolved_models_dir:
|
||||||
|
extra["models_dir"] = _resolved_models_dir
|
||||||
self._start_visualization_thread("generate_all_selected", extra)
|
self._start_visualization_thread("generate_all_selected", extra)
|
||||||
|
|
||||||
def generate_chart(self, chart_type):
|
def generate_chart(self, chart_type):
|
||||||
@ -1684,6 +1704,12 @@ class Step12VizPanel(QWidget):
|
|||||||
QMessageBox.warning(self, "警告", "工作目录不存在!")
|
QMessageBox.warning(self, "警告", "工作目录不存在!")
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
|
main_window = self.window()
|
||||||
|
factory = getattr(main_window, '_panel_factory', None) if main_window else None
|
||||||
|
step5_panel = factory.get_panel('step5_clean') if factory else None
|
||||||
|
if step5_panel and getattr(step5_panel, 'output_file', None) and step5_panel.output_file.get_path():
|
||||||
|
training_spectra_csv = Path(step5_panel.output_file.get_path())
|
||||||
|
else:
|
||||||
training_spectra_csv = _viz_training_spectra_csv_path(work_path)
|
training_spectra_csv = _viz_training_spectra_csv_path(work_path)
|
||||||
if chart_type == 'scatter':
|
if chart_type == 'scatter':
|
||||||
if not training_spectra_csv.is_file():
|
if not training_spectra_csv.is_file():
|
||||||
|
|||||||
Reference in New Issue
Block a user