fix: step_default_outputs 支持列表候选文件名,解决动态命名导致 OutputUpdated 断链

This commit is contained in:
DXC
2026-06-18 10:36:52 +08:00
parent 3f217e95b0
commit 3ee4e90b31

View File

@ -25,9 +25,16 @@ class WorkspaceManager:
def __init__(self):
self.step_default_outputs = {
'step1': {'water_mask': "1_water_mask/water_mask_out.dat"},
'step1': {'water_mask': [
"1_water_mask/water_mask_out.dat",
"1_water_mask/water_mask_from_ndwi.dat",
"1_water_mask/water_mask_from_shp.dat",
]},
'step2': {'glint_mask': "2_Glint_Detection/severe_glint_area.dat"},
'step3': {'deglint_image': "3_deglint/deglint_image.bsq"},
'step3': {'deglint_image': [
"3_deglint/deglint_image.bsq",
"3_deglint/deglint_goodman.bsq",
]},
'step4_sampling': {'sampling_points': "4_sampling/sampling_spectra.csv"},
'step5_clean': {'processed_data': "5_Data_Cleaning/processed_data.csv"},
'step6_feature': {'training_spectra': "6_Spectral_Feature_Extraction/training_spectra.csv"},
@ -100,7 +107,12 @@ class WorkspaceManager:
return candidate
if output_type == 'water_mask':
if rel_path:
if isinstance(rel_path, list):
for candidate in rel_path:
mask_path = work_path / candidate
if mask_path.exists():
return str(mask_path)
elif rel_path:
mask_path = work_path / rel_path
if mask_path.exists():
return str(mask_path)
@ -108,7 +120,12 @@ class WorkspaceManager:
if ref_img_path and Path(ref_img_path).exists():
return ref_img_path
elif output_type == 'deglint_image':
if rel_path:
if isinstance(rel_path, list):
for candidate in rel_path:
deglint_path = work_path / candidate
if deglint_path.exists():
return str(deglint_path)
elif rel_path:
deglint_path = work_path / rel_path
if deglint_path.exists():
return str(deglint_path)
@ -118,7 +135,7 @@ class WorkspaceManager:
return str(file_path)
for file_path in deglint_dir.glob("interpolated_*.bsq"):
return str(file_path)
elif rel_path:
elif isinstance(rel_path, str):
if rel_path.endswith('/'):
output_path = work_path / rel_path.rstrip('/')
if output_path.exists() and output_path.is_dir():
@ -208,7 +225,15 @@ class WorkspaceManager:
published = {}
for output_type, relative_path in step_outputs.items():
if '*' in relative_path:
if isinstance(relative_path, list):
for candidate in relative_path:
output_path = work_path / candidate
if output_path.exists():
path_str = str(output_path)
self.step_outputs.setdefault(step_name, {})[output_type] = path_str
published[output_type] = path_str
break
elif '*' in relative_path:
pattern_path = work_path / relative_path.replace('*', '*')
matching_files = list(pattern_path.parent.glob(pattern_path.name))
if matching_files: