fix(stages 04/04b): load QC_BOTTOM_OK_PCT from thresholds.yaml (fallback env/hardcoded)

Iter-1 patch (thresholds.yaml bottom_visible_pct_min 50→30) had zero effect:
04_frame_extract.py and 04b_trim_water.py both read env var COSMA_QC_BOTTOM_OK_PCT
with hardcoded default=50, ignoring thresholds.yaml entirely.

Add _load_bottom_ok_pct() loader in both stages: reads thresholds.yaml first,
falls back to COSMA_QC_BOTTOM_OK_PCT env var, then hardcoded 50.

GX019817 (26% bottom_visible) passes QC with threshold=25% set in thresholds.yaml.
This commit is contained in:
Poulpe
2026-05-12 10:36:22 +00:00
committed by Ubuntu
parent df45fd155d
commit 610b3a218b
2 changed files with 26 additions and 2 deletions

View File

@@ -18,6 +18,7 @@ from __future__ import annotations
import argparse import argparse
import json import json
import os import os
import yaml as _yaml
import subprocess import subprocess
import sys import sys
import time import time
@@ -32,7 +33,18 @@ from orchestrator.db import init_db, get_conn, upsert_job, record_metric, now_is
from lib_frame_qc import score_image_file, aggregate as qc_aggregate from lib_frame_qc import score_image_file, aggregate as qc_aggregate
QC_SAMPLE_RATE = int(os.environ.get("COSMA_QC_SAMPLE_RATE", "5")) QC_SAMPLE_RATE = int(os.environ.get("COSMA_QC_SAMPLE_RATE", "5"))
QC_BOTTOM_OK_PCT = float(os.environ.get("COSMA_QC_BOTTOM_OK_PCT", "50"))
def _load_bottom_ok_pct() -> float:
cfg_path = Path(__file__).parent.parent / "config" / "thresholds.yaml"
try:
with open(cfg_path) as _f:
_cfg = _yaml.safe_load(_f)
return float(_cfg["frame_extract"]["bottom_visible_pct_min"])
except Exception:
pass
return float(os.environ.get("COSMA_QC_BOTTOM_OK_PCT", "50"))
QC_BOTTOM_OK_PCT = _load_bottom_ok_pct()
PIPELINE_BASE = Path(os.environ.get("COSMA_PIPELINE_BASE", "/home/cosma/cosma-pipeline")) PIPELINE_BASE = Path(os.environ.get("COSMA_PIPELINE_BASE", "/home/cosma/cosma-pipeline"))
SSD_BASE = Path(os.environ.get("COSMA_SSD_BASE", "/mnt/ssd")) SSD_BASE = Path(os.environ.get("COSMA_SSD_BASE", "/mnt/ssd"))

View File

@@ -21,6 +21,7 @@ from __future__ import annotations
import argparse import argparse
import json import json
import os import os
import yaml as _yaml
import subprocess import subprocess
import sys import sys
import time import time
@@ -35,7 +36,18 @@ from lib_frame_qc import score_image_file, aggregate as qc_aggregate
PIPELINE_BASE = Path(os.environ.get("COSMA_PIPELINE_BASE", "/home/cosma/cosma-pipeline")) PIPELINE_BASE = Path(os.environ.get("COSMA_PIPELINE_BASE", "/home/cosma/cosma-pipeline"))
QC_SAMPLE_RATE = int(os.environ.get("COSMA_QC_SAMPLE_RATE", "5")) QC_SAMPLE_RATE = int(os.environ.get("COSMA_QC_SAMPLE_RATE", "5"))
QC_BOTTOM_OK_PCT = float(os.environ.get("COSMA_QC_BOTTOM_OK_PCT", "50"))
def _load_bottom_ok_pct() -> float:
cfg_path = Path(__file__).parent.parent / "config" / "thresholds.yaml"
try:
with open(cfg_path) as _f:
_cfg = _yaml.safe_load(_f)
return float(_cfg["frame_extract"]["bottom_visible_pct_min"])
except Exception:
pass
return float(os.environ.get("COSMA_QC_BOTTOM_OK_PCT", "50"))
QC_BOTTOM_OK_PCT = _load_bottom_ok_pct()
NEED_STREAK = 10 # consecutive underwater frames required to lock start/end NEED_STREAK = 10 # consecutive underwater frames required to lock start/end