Page 4 of 8~120 min topic

Model deployment

Measure whether the versioned prediction HTTP service works

Executable checks prove response includes model_version; unknown feature schema → 422, never silent default on fixtures — including the known misshape behind MODEL-SCHEMA-DRIFT-22.

~15 min this pageEvaluation

1Learn the idea

Read

Schema and policy checks

Add executable validation at the trust boundaries of versioned prediction HTTP service for churn risk scores. Reject unknown fields where they matter, bound string sizes, and coerce only after auth/signature checks when raw bytes are security-relevant. Invariant under test: response includes model_version; unknown feature schema → 422, never silent default. A TypeScript type or Python annotation is not runtime validation — pair them with parsers.

Read

Golden and adversarial fixtures

Automate the fixtures from setup, including a recreation of MODEL-SCHEMA-DRIFT-22. Assert both the visible error and the absence of side effects (no provider call, no queue write, no flag flip). Where metrics matter, assert label enums stay bounded.

Read

Implementation artifact

def validate_schema(feats, schema):
    missing = schema.keys() - feats.keys()
    extra = feats.keys() - schema.keys()
    if missing or extra:
        raise HTTPException(422, detail={"missing": sorted(missing), "extra": sorted(extra)})

Read

Gate semantics

Document which failures are client mistakes (4xx) versus operator/config mistakes (5xx/503). Oracle still stands: fixture row → score in [0,1] with model_version=churn-xgb-1.4.2. Validation should make accidental “success with empty body” impossible for growth analyst calling /v1/predict with customer features.

Read

Stage depth

Property ideas: shuffled field order, Unicode edges, maximum-length strings, and replayed timestamps. Where money, identity, or citations matter, assertion messages should cite the field name. Do not snapshot entire provider payloads in tests; assert semantically. If validation fails open “to keep the demo working,” you have inverted the lab. Tie at least one CI job to the MODEL-SCHEMA-DRIFT-22 fixture so main cannot regress silently. Re-read response includes model_version; unknown feature schema → 422, never silent default after each new parser — convenience helpers love to bypass it.

Read

Field notes for `model-deployment` / `validation`

Table-drive status codes and error codes so reviewers see coverage at a glance. Include a Unicode normalization case if user text is accepted. Verify that oversized bodies fail before CPU-heavy work. Where digests or versions are pinned, assert mismatch behavior. Keep golden files small enough to read in review. CI should fail on skipped tests that mark the incident fixture as xfail without a ticket link. In this chapter the product is versioned prediction HTTP service for churn risk scores, the human stakeholder is growth analyst calling /v1/predict with customer features, and the incident id you design against is MODEL-SCHEMA-DRIFT-22. Re-state the oracle in your notes — fixture row → score in [0,1] with model_version=churn-xgb-1.4.2 — and keep the invariant visible: response includes model_version; unknown feature schema → 422, never silent default. Track schema_reject_rate visible and score_psi ≤ 0.1 vs baseline week as the scoreboard. Surface under change control: POST /v1/predict. If you only have forty minutes, finish the fixture for schema drift drops a feature; scores shift 0.3 without version bump before polishing UI. Promotion language stays ternary: promote, hold, or roll back based on evidence, not hope.

Read

Extra mastery block

For model-deployment, write a transfer example that differs in one constraint from the chapter scenario. Keep the quality bar fixed. Explain which check still applies.

Go deeper

Before you start

Why this matters

List three fixtures: one golden success, one schema/auth reject, and one regression for MODEL-SCHEMA-DRIFT-22. For each, write the exact assertion (status, code, metric, or citation) that must turn red if broken.

In the wild

See how this idea shows up as a product and a company — then come back to the lesson. Skills transfer across vendors.

Check your understanding

Page assessment

Answer from memory. Completion is saved from this evidence, not from opening the next page.

1. Do parsers run before side effects?
2. Is MODEL-SCHEMA-DRIFT-22 represented as a fixture?
3. Are side-effect absences asserted?

All responses are required.