"""#768 test helper: seed image_prediction rows. Read-path tests used to seed ImageRecord(tagger_predictions={...}); predictions now live in the normalized image_prediction table, so seed there instead. """ from backend.app.models import ImagePrediction async def seed_predictions(session, image_id: int, predictions: dict) -> None: """Insert image_prediction rows from a {raw_name: {category, confidence}} dict (the old JSON shape). Caller commits/flushes as needed; this flushes.""" session.add_all([ ImagePrediction( image_record_id=image_id, raw_name=name, category=p.get("category", "general"), score=float(p.get("confidence", 0.0)), ) for name, p in predictions.items() ]) await session.flush()