Page 3 of 8~120 min topic

Model deployment

Build the first working versioned prediction HTTP service

One clean transaction through **POST /v1/predict** must match the oracle: fixture row → score in [0,1] with model_version=churn-xgb-1.4.2.

~15 min this pageImplementation

1Learn the idea

Read

Order the successful transaction

Code the narrow path that serves growth analyst calling /v1/predict with customer features: accept → authorize/normalize → call dependency → validate → record. Keep stages named so a trace can show which boundary passed. Success must emit evidence useful to schema_reject_rate visible and score_psi ≤ 0.1 vs baseline week, not only a 200 with prose. Predict the observable for POST /v1/predict before running: fixture row → score in [0,1] with model_version=churn-xgb-1.4.2.

Read

Run with fakes first

Drive the path with recording fakes or local stubs. Assert call order and arguments. Idempotency keys or stable ids should keep retries from duplicating costly work where the product requires it. Product under test remains versioned prediction HTTP service for churn risk scores — resist adding unrelated features mid-path.

Read

Implementation artifact

@app.post("/v1/predict", response_model=PredictOut)
def predict(body: PredictIn):
    validate_schema(body.features, SCHEMA_V142)
    return PredictOut(score=float(model.predict_proba(vectorize(body.features))[0,1]), model_version=MODEL_VERSION)

Read

Compare prediction to result

For Model deployment, paste the CLI/HTTP transcript beside your prediction for POST /v1/predict. If the oracle is unmet (fixture row → score in [0,1] with model_version=churn-xgb-1.4.2), stop and debug this page; do not compensate with prompt folktales. Re-run once after a clean process start to catch hidden global state that would invalidate MODEL-SCHEMA-DRIFT-22.

Read

Stage depth

Performance sketch: measure local p95 for the fake-backed path so later regressions are obvious. Keep concurrency modest until failure-handling proves limits. Log a single structured event per success with request id, revision, and the evidence field behind schema_reject_rate visible and score_psi ≤ 0.1 vs baseline week. Avoid hidden global caches in the happy path unless the lab is about caching — and even then key by tenant. If the path calls a model, pin model id in config and echo it in the response for auditability. Remember growth analyst calling /v1/predict with customer features experiences wall-clock time, not your debugger’s single-step comfort.

Read

Field notes for `model-deployment` / `happy-path`

Prefer explicit function names over a single god-object handleRequest. Thread a correlation id from ingress to the last log line. When streaming, define what partial failure means before coding. Snapshot one successful response body in fixtures after redaction. If the path writes to a queue, assert message attributes in the fake. Stop adding retries on this page; that is the next concern. 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.

Go deeper

Before you start

Why this matters

Without calling production, order the steps a single success takes for growth analyst calling /v1/predict with customer features. Circle the first irreversible side effect. Your prediction should mention POST /v1/predict and the evidence field that proves fixture row → score in [0,1] with model_version=churn-xgb-1.4.2.

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. Is call order asserted, not assumed?
2. Does success evidence support schema_reject_rate visible and score_psi ≤ 0.1 vs baseline week?
3. Did you compare prediction vs transcript?

All responses are required.