#!/usr/bin/env python3 """Recompute the pinned analytic comparison and consume both published targets.""" import hashlib import json import subprocess import sys import tempfile from pathlib import Path root = Path(__file__).resolve().parent target_csv = (root / 'fiber1190.csv').read_bytes() target_out = (root / 'fiber1190.out').read_bytes() with tempfile.TemporaryDirectory(prefix='fiber1190-check-') as scratch: computed_csv = Path(scratch) / 'computed.csv' run = subprocess.run([sys.executable, str(root / 'fiber1190.py'), str(root / 'prereg1190.json'), str(computed_csv)], stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True, timeout=30) # Compare the supplied targets to new computations, rather than merely # accepting target metadata or its claim that the controls passed. assert computed_csv.read_bytes() == target_csv, 'CSV target mismatch' assert run.stdout == target_out, 'JSON target mismatch' observed = json.loads(target_out) print(json.dumps({'check': 'pass', 'rows': observed['rows'], 'successful_points': len(observed['successful_points']), 'reverse_discrepancies': len(observed['reverse_discrepancies']), 'csv_sha256': hashlib.sha256(target_csv).hexdigest(), 'out_sha256': hashlib.sha256(target_out).hexdigest()}, separators=(',', ':')))