Python, PyTest & SQL Foundations for AI QE Β· Day 2 Β· 20 min
Parameterized Golden Datasets & Rubrics
Python, PyTest & SQL Foundations for AI QE β Day 2
Drive @pytest.mark.parametrize over JSONL and CSV golden datasets covering happy paths, edge cases, vulnerable-user queries, and foreseeable misuse with strict category pass-rate thresholds.
π¦Sample Codebase & Working Solution (Day 2)Available Now
View on GitHubThe official reference codebase for Day 2 is hosted in the repository. Clone the repository and navigate to day-2-golden-datasets/test_day2_golden_datasets.py to run the working solution.
Git Clone β Working Solution
git clone https://github.com/777abhi/pytest-sql-ai-qe-roadmap.git
cd pytest-sql-ai-qe-roadmap/day-2-golden-datasets/test_day2_golden_datasets.pyπProduction Context & Enterprise Implementation
π‘ Why We Are Doing This: Hardcoded string equality breaks on natural-language AI answers, while a single aggregate pass rate can hide critical failures on vulnerable-user hardship or foreseeable-misuse prompts.
π’ Real-World Production Usecase: Data-driven regression suites maintained jointly by QE engineers, domain SMEs, and compliance reviewers in Git-versioned JSONL and CSV files.
βοΈ How Implemented in Production: load_jsonl_dataset and load_csv_dataset feed @pytest.mark.parametrize; score_response enforces zero-tolerance forbidden terms and evaluate_dataset asserts per-category pass-rate floors.
Phase 1
Run Parameterized JSONL & CSV Golden Datasets
Step 1.1: Execute Day 2 Parameterized Suite
Terminal β Run Day 2
npm run test:day2Step 1.2: Per-Category Pass-Rate Thresholds
day-2-golden-datasets/test_day2_golden_datasets.py
report = evaluate_dataset(
combined,
category_thresholds={
"happy_path": 0.90,
"edge_case": 0.85,
"vulnerable_user": 1.00,
"foreseeable_misuse": 1.00,
},
)
assert report["breaches"] == []Day 2 Key Learnings
- Parameterized PyTest cases directly from Git-tracked JSONL and CSV golden datasets with readable case IDs.
- Enforced zero-tolerance forbidden-keyword checks so a single unsafe phrase scores 0.0 immediately.
- Applied stricter 100% pass-rate thresholds to vulnerable_user and foreseeable_misuse slices than general happy paths.
π§ Knowledge Check
Why should regulated AI evaluation suites enforce per-category pass-rate thresholds (e.g. 100% on vulnerable_user and foreseeable_misuse) rather than relying only on an overall pass rate?