Lesson 1 of 5 MLOps Orchestration and Model Versioning

Orchestrating Model Building with SageMaker Pipelines

This lesson explains SageMaker Pipelines, the ML-native workflow service that defines building, evaluating and registering a model as a directed acyclic graph that runs serverlessly and records lineage.

Learning outcomes

After completing this lesson, you will be able to:

  • Identify the pipeline step types.
  • Use parameters and step caching.
  • Build a gated pipeline with a condition step.

Steps

A pipeline is a set of steps with dependencies. ProcessingStep runs data preparation or evaluation scripts; TrainingStep trains a model; TuningStep runs automatic model tuning; ModelStep creates or registers a model; TransformStep runs batch transform; ConditionStep branches on values such as evaluation metrics; ClarifyCheckStep and QualityCheckStep compute bias and data or model quality baselines; LambdaStep and CallbackStep integrate other services or wait for external work; FailStep stops with a message. The @step decorator turns Python functions into steps. EMR steps and notebook jobs are also supported.

Match the pairs

Pipeline steps

Exam skills 3.3.3 · 3.3.5

Match each SageMaker Pipelines step type with its job.

Log in to try this activity Interactive activities are free with an account.

Parameters, caching and execution

Pipeline parameters (such as input data location, instance type or accuracy threshold) are set per execution, so one definition serves many environments and runs. Step caching reuses the output of a step whose inputs have not changed, saving time and cost when rerunning a pipeline after a later step fails. Executions can be started from the console, SDK, EventBridge rules or schedules, and every execution records lineage linking data, jobs and model versions. Pipelines integrate with the Model Registry and with SageMaker Projects for CI/CD.

Typical structure

A standard model-building pipeline in SageMaker Pipelines follows a common sequence. A processing step prepares the data, a training step trains the model, and an evaluation step measures it on a test set. A condition step then checks whether the model is good enough, for example whether its accuracy exceeds a threshold or beats the current production model. Only if it passes does a step register the model as a new version in the Model Registry, with its approval status set to pending, so a person or automated gate decides on deployment. The following table maps the steps to their purposes.

Step typeTypical purpose
ProcessingStepFeature engineering, data validation, evaluation metrics
TrainingStep / TuningStepTrain or tune the model
QualityCheckStep / ClarifyCheckStepCreate Model Monitor and Clarify baselines
ConditionStepQuality gate on evaluation metrics
ModelStep (register)Add a version to a model package group
CallbackStep / LambdaStepWait for or call external systems
FailStepStop with a clear reason

The following diagram shows the steps of a weekly churn training pipeline and the two outcomes of its quality gate.

The weekly churn pipeline. Processing, training and evaluation steps run in order; a ConditionStep reads the AUC from the evaluation report and, only if it is at least the auc_threshold parameter, registers the model in the churn-models group as PendingManualApproval. Otherwise a FailStep stops the run with a clear reason.
The threshold is a pipeline parameter, so it changes without editing the definition.
Put in order

A gated pipeline

Exam skills 3.3.5 · 3.3.6

Arrange the steps of a typical model building pipeline.

Log in to try this activity Interactive activities are free with an account.
Worked example

A gated training pipeline

A churn model must be retrained weekly and registered only if its validation AUC is at least 0.80.

evaluate = ProcessingStep(name="Evaluate", processor=sk_processor, code="evaluate.py",
                          property_files=[eval_report], ...)
register = ModelStep(name="Register", step_args=model.register(
    model_package_group_name="churn-models", approval_status="PendingManualApproval", ...))
gate = ConditionStep(
    name="AUCAtLeast080",
    conditions=[ConditionGreaterThanOrEqualTo(
        left=JsonGet(step_name="Evaluate", property_file=eval_report, json_path="metrics.auc.value"),
        right=auc_threshold)],                      # pipeline parameter, default 0.80
    if_steps=[register],
    else_steps=[FailStep(name="AUCTooLow", error_message="AUC below threshold")])
pipeline = Pipeline(name="churn-train", parameters=[input_data, auc_threshold],
                    steps=[process, train, evaluate, gate])

The gate prevents weak models from even reaching the registry, and the threshold is a parameter, so it can be changed without editing the pipeline definition.

Check yourself

How does a pipeline skip steps whose inputs have not changed?

Show answer

With step caching.

Exam Tips

Remember for the exam

  • ML-native workflow with lineage and registry integration: SageMaker Pipelines.
  • Quality gate on metrics: ConditionStep with JsonGet from an evaluation report.
  • Skip unchanged steps on rerun: step caching.
  • Wait for external systems or approvals: CallbackStep.
  • Pipeline parameters let one definition serve many runs and environments.