Week 2 • Day 7100% FREE
Day 7:Mini-Project (Async Schema-Validated Runbook Batch Processor) + Week 2 Mock Interview
Battle-tested daily lesson note • 100% runnable code, interview Q&A, test suite & interactive quiz
Week 2 — Day 7: Mini-Project (Async Schema-Validated Runbook Batch Processor) + Week 2 Mock Interview
Mentor's Note (10+ YOE Staff AI Engineer POV): Look at how far you have come in 2 weeks! In Week 1 Day 7, we built a synchronous pure-Python runbook search script. Today in Week 2 Day 7, we combine all 6 days of Week 2:
- Day 1: Lazy Generators (
yield) to stream incoming incident queries inO(1)RAM.- Day 2: Pydantic v2 (
RunbookResponse&TokenUsageAudit) to strictly validate every output and calculate exact token USD costs.- Day 3:
asyncio.gather()+asyncio.Semaphoreto process multiple incident queries concurrently without hitting rate limits.- Day 4:
ResilientRunbookCopilotwith automatic self-correction when an LLM response fails Pydantic validation, tested deterministically withAsyncMock.- Day 5: Structured JSON Telemetry Logging (
create_json_logger) emitting machine-parsabletrace_id,latency_ms, andcost_usdlogs for every query!- Day 6: Verified clean of any AST violations (
audit_python_source).
Running the Week 2 Mini-Project & Test Suite
powershell
# 1. Run the Week 2 Async Validated Runbook Pipeline:
python week02_advanced_python_pydantic_asyncio_tests/day07_week2_mini_project_async_pipeline/src/async_runbook_pipeline.py
# 2. Run the Week 2 End-to-End Automated Test Suite:
python -m unittest discover -s week02_advanced_python_pydantic_asyncio_tests/day07_week2_mini_project_async_pipeline/tests -v
In Simple English: How the Pipeline Connects (Restaurant Analogy)
Think of this Week 2 mini-project like running a busy pizza kitchen:
- Lazy Generator (Order Ticket Printer): Instead of printing 10,000 orders onto paper at once and crashing the table (OOM RAM crash), it prints 1 ticket at a time (
yield). - Pydantic v2 Schema (Quality Inspector): Checks that every pizza has a valid size, toppings, and price before leaving the oven — catching hallucinated fields instantly.
asyncio.Semaphore(5)(5 Ovens Working at Once): Cooks 5 orders concurrently instead of waiting for Pizza #1 to finish before starting Pizza #2 (5x faster), without letting 500 cooks crash the kitchen (rate-limit protection).- Auto-Retry + JSON Logs (Black-Box Flight Recorder): If a chef forgets a topping, the inspector sends a polite correction note once; meanwhile, every millisecond and dollar spent is saved cleanly as structured JSON.
Interactive Lab: Open Tab 2 (Codes) and Tab 4 (Test & Troubleshooting) to inspect the pipeline and tests.