fix(04/04b): load QC_BOTTOM_OK_PCT from thresholds.yaml #9

Open
poulpe wants to merge 2 commits from fix/threshold-yaml-source into feature/auto-pipeline
2 changed files with 26 additions and 2 deletions
Showing only changes of commit 610b3a218b - Show all commits

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