Skip to content

Commit bc78592

Browse files
authored
Merge pull request #519 from sensein/feat/pii-subprocess-venv
Feat/pii subprocess venv
2 parents 183529a + 6429b48 commit bc78592

5 files changed

Lines changed: 1321 additions & 239 deletions

File tree

src/senselab/audio/workflows/audio_analysis/global_summary.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,14 +280,34 @@ def compute_pass_global_summary(
280280

281281
# ─── no_pii ───
282282
# Surface the actual detected PII spans (text + category + detector + ASR
283-
# source + confidence) so the consumer can audit. The boolean ``contains_pii``
284-
# flag drives the bottom-line uncertainty; the span list lets a reviewer
285-
# decide whether each detection is a true positive worth redacting.
283+
# source + confidence) so the consumer can audit. The continuous
284+
# ``detection_confidence`` (per-span score × cross-detector agreement ×
285+
# cross-ASR agreement) drives the bottom-line uncertainty; the boolean
286+
# ``contains_pii`` and the span list let a reviewer decide whether each
287+
# detection is a true positive worth redacting. ``None`` propagation:
288+
# ``pii_report is None`` (PII stage skipped upstream) or
289+
# ``pii_report.detector_used is None`` (subprocess crashed / both
290+
# detectors failed to load / caller passed ``detectors=[]``) both
291+
# surface as ``no_pii_uncertainty = None`` — distinct from ``0.0``
292+
# ("ran, found nothing") so a downstream auditor can tell "didn't
293+
# check" from "checked clean".
286294
if pii_report is None:
287295
no_pii_uncertainty: float | None = None
288296
pii_block: dict[str, Any] | None = None
297+
elif pii_report.detector_used is None:
298+
no_pii_uncertainty = None
299+
pii_block = {
300+
"contains_pii": pii_report.contains_pii,
301+
"n_spans": pii_report.n_spans,
302+
"categories": pii_report.categories,
303+
"detector_used": None,
304+
"detection_confidence": None,
305+
"spans_by_category": {},
306+
"spans": [],
307+
"failures": pii_report.failures,
308+
}
289309
else:
290-
no_pii_uncertainty = 1.0 if pii_report.contains_pii else 0.0
310+
no_pii_uncertainty = pii_report.detection_confidence
291311
# Group spans by category for a quick at-a-glance view; full per-span
292312
# detail lives alongside.
293313
from collections import defaultdict
@@ -307,6 +327,7 @@ def compute_pass_global_summary(
307327
"n_spans": pii_report.n_spans,
308328
"categories": pii_report.categories,
309329
"detector_used": pii_report.detector_used,
330+
"detection_confidence": pii_report.detection_confidence,
310331
"spans_by_category": dict(spans_by_category),
311332
"spans": [
312333
{

0 commit comments

Comments
 (0)