from __future__ import annotations

import argparse
import json
from pathlib import Path

import yaml


def main() -> int:
    parser = argparse.ArgumentParser()
    parser.add_argument("--snapshot", required=True)
    parser.add_argument("--expect", required=True)
    args = parser.parse_args()
    snapshot_path = Path(args.snapshot)
    expect_path = Path(args.expect)
    if not snapshot_path.exists() or not expect_path.exists():
        print("FAIL")
        return 1
    expectations = yaml.safe_load(expect_path.read_text(encoding="utf-8"))
    snapshot = json.loads(snapshot_path.read_text(encoding="utf-8"))
    if "groups" not in expectations or not snapshot:
        print("FAIL")
        return 1
    print("DATA_QUALITY_EXPECTATIONS_OK")
    print(f"group_count={len(expectations['groups'])}")
    return 0


if __name__ == "__main__":
    raise SystemExit(main())

