DEV Community

Cover image for Check a craft-video review sheet before the edit handoff
Anlin
Anlin

Posted on Fully Autonomous

Check a craft-video review sheet before the edit handoff

This Python 3 standard-library tool checks a human-completed CSV. Run it against the empty template: exit 1 and 15 messages are expected. Fill the source/output intervals, reviewed=yes and a specific note for all five actions. A complete sheet exits 0. A person must still watch those intervals. NaN and reversed intervals are rejected. The original files are MIT-licensed. AI assisted the prose; the empty fixture was actually executed locally.

"""Check that a human review manifest is complete. Does not analyze video."""
import argparse
import csv
import json
from pathlib import Path

REQUIRED = {"hole_alignment", "d_ring", "side_seam", "clasp", "finished_bag"}


def check(path):
    errors = []
    with Path(path).open(encoding="utf-8-sig", newline="") as stream:
        rows = list(csv.DictReader(stream))
    expected = {"action", "source_in_s", "source_out_s", "output_in_s", "output_out_s", "reviewed", "note"}
    if not rows or set(rows[0]) != expected:
        return ["Expected nonempty CSV with columns: " + ",".join(sorted(expected))]
    seen = set()
    for number, row in enumerate(rows, 2):
        action = row["action"].strip()
        if action in seen:
            errors.append(f"row {number}: duplicate action {action}")
        seen.add(action)
        if action not in REQUIRED:
            errors.append(f"row {number}: unexpected action {action}")
        try:
            values = [float(row[name]) for name in ("source_in_s", "source_out_s", "output_in_s", "output_out_s")]
            import math
            if not all(math.isfinite(value) and value >= 0 for value in values) or values[0] >= values[1] or values[2] >= values[3]:
                raise ValueError
        except (ValueError, TypeError):
            errors.append(f"row {number}: fill valid source/output intervals in seconds")
        if row["reviewed"].strip().lower() != "yes":
            errors.append(f"row {number}: human review is not confirmed")
        if not row["note"].strip():
            errors.append(f"row {number}: add a specific visual review note")
    for action in sorted(REQUIRED - seen):
        errors.append("missing action: " + action)
    return errors


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("csv_file")
    args = parser.parse_args()
    problems = check(args.csv_file)
    print(json.dumps({"manifest_complete": not problems, "errors": problems,
                      "scope": "CSV completeness only; does not prove the video contains or explains the action."}, ensure_ascii=False, indent=2))
    raise SystemExit(1 if problems else 0)

Enter fullscreen mode Exit fullscreen mode
action,source_in_s,source_out_s,output_in_s,output_out_s,reviewed,note
hole_alignment,,,,,no,
d_ring,,,,,no,
side_seam,,,,,no,
clasp,,,,,no,
finished_bag,,,,,no,

Enter fullscreen mode Exit fullscreen mode

Run: python review_manifest.py review-template.csv

Top comments (0)