Return to the valid source after the controlled data fault, run the checked pipeline again and keep traffic unchanged until a release decision.
Problem
When you need this. The investigation found an invalid input. It did not show that a new fit would improve the model. Recovery starts by choosing a valid source and keeping the failed example, not by training on the broken input.
This final exercise uses the original valid scenario in a fresh pipeline workspace, fits an actual candidate and applies the unchanged release policy. It then checks that the routing configuration is the same as before the fit.
Concepts
Recovery restores the application’s intended behavior. Depending on the cause, that can mean repairing ingestion, restoring artifact availability or selecting a compatible release. Retraining is one possible follow-up; it is not the universal repair. When the diagnosis reports invalid data, fix the source before you fit: the pipeline refuses an invalid event batch and writes no candidate.
A new training run gets a new run identity even when it fits identical parameters. This exercise uses the same fixture, recipe and splits, so expect no model improvement. The purpose is to check that a recovered input path can still produce a loadable, evaluated candidate.
The same release policy applies. Passing it permits the local rollout exercise, but traffic selection is a separate step. The new candidate does not automatically move the routing head.
The sequence now closes the six-stage lifecycle: an application requirement became a manual model, a reproducible run, a checked pipeline, a selected release and an operated prediction path. The original observation, feature and model contracts remain visible through those handoffs.
Architecture
Working code
Download the shared application and tests, unzip it and enter mlops-return-workflow/. Keep the same directory throughout the course. Create the environment once. Install the pinned platform dependencies for this workshop.
python3.12 -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements-platform.txtOn PowerShell, activate with .venv\Scripts\Activate.ps1.
Continue from Investigate changed inputs before choosing a response; keep the same lab directory and outputs.
Recover through the existing pipeline
The command fits into a separate recovery-training folder inside the workspace, so the failed and recovered attempts stay apart. Training reads the original valid authored scenario, scenario.json; the deliberately invalid drift input is left out.
def recovery_report(root):
need(root,'drift.json');routing=rollout.Routing(root/'routing.sqlite')
try:before=routing.current()
finally:routing.close()
# Operator chooses the original valid source after the invalid-input drill.
# This is a fresh actual fit, not approval to switch traffic.
result=pipeline.run(w.HERE/'scenario.json',root/'recovery-training')
w.save(root/'recovery-state.json',result);_,source=release.candidate_files(root/'recovery-state.json')
decision=release.gate(source/'outputs/cohort.json',source/'outputs/candidate.json')
w.save(root/'recovery-gate.json',decision)
routing=rollout.Routing(root/'routing.sqlite')
try:after=routing.current()
finally:routing.close()
if before!=after:raise ValueError('recovery unexpectedly changed traffic')
return {'source':'original valid authored scenario; invalid drill inputs excluded','new_training_run':result['run_id'],
'gate_passed':decision['passed'],'policy_unchanged':decision['policy']==release.POLICY,
'traffic_unchanged':before==after,'automatic_promotion':False,'final_test_used':False}
HANDLERS=dict(zip(TOPICS,[pipeline_report,retry_report,ci_report,gate_report,registry_report,serving_report,rollout_report,rollback_report,monitoring_report,delayed_report,drift_report,recovery_report]))python course.py recovery --workspace work/course{
"source": "original valid authored scenario; invalid drill inputs excluded",
"new_training_run": "110b82203fdf48cd9178430d283fca4b",
"gate_passed": true,
"policy_unchanged": true,
"traffic_unchanged": true,
"automatic_promotion": false,
"final_test_used": false
}The command runs an actual CPU fit through Prefect and MLflow. The gate evaluates the candidate with the same release policy and does not use the reserved final test. Read gate_passed and policy_unchanged together: a pass under a different policy is not comparable with the earlier gate results.
Retain the current serving decision
The command reads the complete routing configuration before and after the new fit. If the two differ, it fails with recovery unexpectedly changed traffic. Any rollout after a release decision still goes through the explicit staging operation from the release stage.
def investigate(reference,current,quality):
try:drift=distribution(reference,current)
except ValueError as e:return {'decision':'repair data before retraining','reason':str(e),'retrain':False}
if quality['scored']==0:return {'decision':'wait for finalized outcomes','drift':drift,'retrain':False}
if quality['accuracy']<0.60:return {'decision':'investigate data and candidate errors; evaluate any new model with the same gate','drift':drift,'retrain':False}
return {'decision':'investigate distribution change' if drift['investigate'] else 'continue observing','drift':drift,'retrain':False}investigate returns 'retrain': False in every branch and never reads or writes routing, so the earlier diagnosis neither starts a fit nor promotes anything. The recovered candidate and its gate report sit beside the unchanged stable release.
The output above is from a saved run in recorded-platform/; your commands write to work/. Read the actual command records. For another attempt, use a fresh work directory: course.py refuses to overwrite an existing topic output.
Failure cases
The command fails if the new pipeline or gate computation raises an error; it retains the attempted workspace. It never changes the policy to rescue a failed candidate.
The reusable integration suite covers invalid input, incomplete attempts, artifact changes, failed gates and rollback history. The final course command also checks that the actual recovery run leaves traffic unchanged.
python -m unittest -v test_platform.pyRunning and scaling the workshop
Keep recovery-state.json and recovery-gate.json with the original command log. Compare the new run identity, model identity and policy identity before considering another rollout.
A real incident needs source-system repair records, an owner-approved recovery decision and representative post-repair observations. This synthetic exercise does not measure incident recovery time, retention benefit or production reliability.
Key takeaways
- Repair the diagnosed failure before deciding whether fitting is useful.
- A new run must satisfy the same checks.
- A passing candidate does not automatically change traffic.
Best practices
Preserve the failed attempt and the recovered run.
Confirm the stable prediction path while a new candidate awaits review.
Check your understanding
If the recovery fit produces the same model parameters, was the exercise pointless?
Show the explanation
No. It checks the recovered data-to-candidate path and its release boundaries. It does not measure improved model quality.
Read the explanation
The repaired workflow produces and evaluates a candidate under the unchanged policy. It leaves the current traffic selection unchanged.