Monitoring and retraining
Drift says the inputs changed, not why. An upstream data bug, a seasonal blip and a real change look the same, so Pipewright does not retrain blindly: drift or a performance drop opens a retrain decision case with a short decision pack, and named approver groups decide. Nothing trains until the required groups agree, and production never trains at all when the closed loop is on.
What is measured on every scoring run
monitoring:
output_table: churn_model_monitoring
drift: { enabled: true, method: psi, threshold: 0.2 } # per feature, against training
prediction_drift: { enabled: true, threshold: 0.2 }
performance:
enabled: true
metric: auc
min: 0.7
labels: { table: churn_outcomes, key: customer_id, label: churned, time_column: outcome_date }
alerts:
notify: [ml-team@example.com]
events: [monitoring.alert, training.rejected, run.failed]
- Feature drift: the population stability index (PSI) of each feature against the training baseline in the evaluation record.
- Prediction drift: the same for the model’s scores; a multi-class model compares its share of each predicted class (a class training never predicted counts as drift).
- Performance: once outcomes arrive, the latest score of each key is joined to its outcome and the metric computed as in evaluation. With
time_column, each outcome is joined to the score made for its cut-off. - Results go to
output_tableand amonitoring.recordedevent; an alert also recordsmonitoring.alert.
pipewright alerts sync creates the email alert policies in Cloud Monitoring from monitoring.alerts. pipewright monitor status --env prod --usecase churn shows drift, performance and open cases.
What an alert leads to
retraining:
mode: propose # off | propose | candidate
when: [drift, performance] # what may open a case (also: schedule)
cooldown_days: 7
decisions: { notify: [ml-leads@example.com], escalate_after_days: 3, digest: true, publish: true }
approvals: { required: [ml-leads, model-risk], separate_from_requester: true }
snooze: { max_days: 14, reopen_when_worse_by: 0.1 }
mode | What happens |
|---|---|
off | Alerts only |
propose | A case opens and people decide; an approved case trains |
candidate | A candidate is trained at once, but never promoted without a person; with the loop on, the loop runs it |
The platform can limit the modes (policies.retraining.allowed_modes), add required groups to every use case, and cap snoozes.
Retrain decision cases
pipewright retrain list --env prod --usecase churn
pipewright retrain show --env prod --usecase churn # the decision pack
pipewright retrain approve --env prod --usecase churn --reason "real shift after the price change"
pipewright retrain decline --env prod --usecase churn --because data-problem --reason "upstream bug, fixed" --days 14
pipewright retrain snooze --env prod --usecase churn --because seasonal --reason "holiday peak" --days 7
- The decision pack says what moved and by how much, the trend over recent runs, data checks that suggest an upstream problem, the champion’s performance, and what retraining would use.
- Approver groups are Pub/Sub topics registered in the manifest: whoever may publish to a group’s topic is a member, so IAM decides. One approval per required group; the requester cannot approve their own case unless allowed.
- Why, in a word: a decline or snooze takes
--becausedata-problem,seasonal,no-harmorother, with a--reasonin your words;--groupsays which approver group you act for. - Snoozes and declines expire, and a case re-opens early when things get worse by
reopen_when_worse_by. - Escalation and digest: undecided cases escalate after
escalate_after_days; a weekly digest summarises open cases. Withpublish, decision events also go to the team’s decision feed for its own apps. - Decisions can also wait in GitHub: decisions approved in GitHub.
When retraining fails
An approved retrain whose training fails keeps its approval: nobody has to decide again. The launcher records how the training ended on the case: a registered version, a version the gates rejected (the case closes), or a failure with the failed step and its error. Transient failures (capacity, quota, preemption) retry automatically, at most twice. Anything else waits for a fix, then:
pipewright retrain retry --env prod --usecase churn --case <id> --reason "contract fixed"
The closed retrain loop: production never trains
With retraining.loop.enabled in production’s configuration, an approved case is trained in the environment production’s releases come from (usually test), on production’s data read in place, compared with the model production serves, then promoted only with a production approval.
pipewright loop start --env prod --usecase churn --case rc-20261024-1a2b3c # trains in test
pipewright loop advance --env prod --usecase churn --case rc-20261024-1a2b3c # the next step when the last is done
pipewright loop advance --env prod --usecase churn --case rc-20261024-1a2b3c --approve # promote, approve, verify
pipewright loop show --env prod --usecase churn --case rc-20261024-1a2b3c
pipewright loop rollback --env prod --usecase churn --case rc-20261024-1a2b3c --reason "complaints"
The steps: training in test; a scoring run in test with the candidate on current data; the production approval, which promotes it and makes it the default; a scoring run in production to verify it. One loop runs at a time per use case; each step is recorded on the case as loop.<state>. The pipewright-decisions workflow advances loops without a person.
Safeguards, canary and data (1.4.0)
| Setting | What it does |
|---|---|
loop.safeguards | For loops started without a person: at most max_loops per per_days; after pause_after_failures failed loops in a row, automatic retraining pauses until pipewright loop resume; drift counts only after drift_runs alerting runs in a row. safeguards: {} gives 1 loop per 7 days, a pause after 2 failures and drift on 2 runs |
loop.canary | The production approval deploys the candidate as a canary; after soak_minutes its error rate and latency are compared with the current version’s in Cloud Monitoring. Healthy, it takes all traffic; otherwise it is removed without a person |
loop.data: production | The training run in test reads production’s feature tables and label window; test’s launcher accepts them only from the production project its manifest names for the tenant |
pipewright loop pause | resume --env prod --usecase churn --reason "..." pauses automatic retraining by hand, recorded with your name. BigQuery ML use cases join the loop with model.promotion: model (linear and logistic regression).
For a model behind an endpoint, Serving health and live quality (1.4.3) adds health alerts per deployed version and runs these same monitor steps on a sample of live calls; A/B testing shows whether a candidate is better for the business before it becomes the champion.