Concept
Automated testing in ML pipelines
Which tests to automate for ML code, data and models, and where each one runs.
Unit tests
- It checks
- Transform and feature code
- Runs in
- CodeBuild, every commit
Data validation
- It checks
- Schema, nulls, ranges
- Runs in
- Glue Data Quality or Processing
Quality gate
- It checks
- Metric above a threshold
- Runs in
- Pipelines Condition step
Regression test
- It checks
- Not worse than production
- Runs in
- Evaluation step
Integration test
- It checks
- Requests and answers work end to end
- Runs in
- Staging endpoint
Load test
- It checks
- Latency and errors under load
- Runs in
- Staging endpoint
| Test | It checks | Runs in |
|---|---|---|
| Unit tests | Transform and feature code | CodeBuild, every commit |
| Data validation | Schema, nulls, ranges | Glue Data Quality or Processing |
| Quality gate | Metric above a threshold | Pipelines Condition step |
| Regression test | Not worse than production | Evaluation step |
| Integration test | Requests and answers work end to end | Staging endpoint |
| Load test | Latency and errors under load | Staging endpoint |
1 / 2
Unit tests
- It checks
- Transform and feature code
- Runs in
- CodeBuild, every commit
Data validation
- It checks
- Schema, nulls, ranges
- Runs in
- Glue Data Quality or Processing
Quality gate
- It checks
- Metric above a threshold
- Runs in
- Pipelines Condition step
| Test | It checks | Runs in |
|---|---|---|
| Unit tests | Transform and feature code | CodeBuild, every commit |
| Data validation | Schema, nulls, ranges | Glue Data Quality or Processing |
| Quality gate | Metric above a threshold | Pipelines Condition step |
2 / 2
Regression test
- It checks
- Not worse than production
- Runs in
- Evaluation step
Integration test
- It checks
- Requests and answers work end to end
- Runs in
- Staging endpoint
Load test
- It checks
- Latency and errors under load
- Runs in
- Staging endpoint
| Test | It checks | Runs in |
|---|---|---|
| Regression test | Not worse than production | Evaluation step |
| Integration test | Requests and answers work end to end | Staging endpoint |
| Load test | Latency and errors under load | Staging endpoint |
- 1A commit starts the pipeline.
- 2Unit tests run in CodeBuild.
- 3The pipeline trains and evaluates the model, and a gate checks the metric.
What it is
An ML pipeline needs more tests than code alone. Unit tests check transform and feature code with small fixed inputs. They run in AWS CodeBuild on every commit, before any training. Data validation checks the new data for schema, missing values and ranges, for example with AWS Glue Data Quality or a SageMaker AI Processing step. Bad data stops the run before it costs training time.
What it is
After training, a model quality gate compares an evaluation metric with a fixed threshold in a Condition step. A regression test compares the new model with the current production model on the same held-out data and fails if it is worse. Then deploy to a staging endpoint. An integration test sends real-shaped requests and checks the format and the answers. A load test checks latency and error rate at the expected traffic, with a load tool run from CodeBuild.
What it is
Order the tests from cheap to costly: unit tests first, then data checks, then training and the quality gate, then staging tests, then an approval before production. A failure at any gate stops the pipeline. Keep the test data and the thresholds in version control so runs are repeatable.
Remember
- Unit tests: transform and feature code, in CodeBuild on each commit.
- Data validation: schema, nulls and ranges before training.
- Quality gate: a metric threshold in a Condition step.
- Regression test: the new model must not be worse than the current one.
- Integration and load tests run against a staging endpoint.
Remember
- Run cheap tests first. Any failed gate stops the pipeline.
On the exam
- “Stop the pipeline when new data has unexpected nulls” points to a data validation gate before training.
- “Do not promote a model that scores below the production model” points to a regression test against the champion.
- “Check p95 latency before production” points to a load test on a staging endpoint.
- “Test the feature code on every commit” points to unit tests in CodeBuild.
In this task · 3.3
- Deployment strategies and rollback
CodePipeline
CodeBuild
CodeDeploy
SageMaker Pipelines
- Automated testing in ML pipelines
- Triggering retraining
Model Registry
Prompt Management
- Agent deployment pipelines and versions
- AI model and prompt testing
- Automating FM deployment and fine-tuned model versions
- RAG update and knowledge base refresh pipelines
Step Functions