Bird
Raised Fist0
MLOpsdevops~5 mins

Model approval workflows in MLOps - Commands & Configuration

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Introduction
When you train machine learning models, you want to make sure only good models get used in real projects. Model approval workflows help you check and approve models before they go live. This keeps your system safe and reliable.
When you want to review a new model's performance before using it in production.
When multiple team members need to approve a model before deployment.
When you want to keep track of which models were approved and when.
When you want to automate the approval process to avoid manual errors.
When you want to reject models that do not meet quality standards.
Commands
This command registers a trained model from a specific run into the model registry with the name 'my_model'. It prepares the model for approval and deployment.
Terminal
mlflow models register -m runs:/1234567890abcdef/model -n my_model
Expected OutputExpected
Successfully registered model 'my_model' with version 1
-m - Specifies the model path from the run to register
-n - Names the registered model
This command moves the registered model version 1 to the 'Staging' stage, indicating it is ready for testing and review before approval.
Terminal
mlflow models transition --model-name my_model --version 1 --stage Staging
Expected OutputExpected
Model 'my_model' version 1 transitioned to stage 'Staging'
--model-name - Specifies the model to transition
--version - Specifies the model version to transition
--stage - Specifies the target stage for the model
After review and approval, this command moves the model to the 'Production' stage, meaning it is approved and ready for real use.
Terminal
mlflow models transition --model-name my_model --version 1 --stage Production
Expected OutputExpected
Model 'my_model' version 1 transitioned to stage 'Production'
--model-name - Specifies the model to transition
--version - Specifies the model version to transition
--stage - Moves the model to the approved production stage
This command lists all versions of the model 'my_model' along with their current stages, so you can see which models are approved or still in review.
Terminal
mlflow models list-versions --model-name my_model
Expected OutputExpected
Version 1: Production Version 2: None Version 3: Staging
--model-name - Specifies the model to list versions for
Key Concept

If you remember nothing else from this pattern, remember: model approval workflows let you control which models are safe and ready to use by moving them through stages like Staging and Production.

Code Example
MLOps
import mlflow

# Register a model from a run
model_uri = "runs:/1234567890abcdef/model"
model_name = "my_model"

result = mlflow.register_model(model_uri, model_name)
print(f"Registered model version: {result.version}")

# Transition model to Staging
client = mlflow.MlflowClient()
client.transition_model_version_stage(
    name=model_name,
    version=result.version,
    stage="Staging"
)
print(f"Model version {result.version} moved to Staging")

# After approval, transition to Production
client.transition_model_version_stage(
    name=model_name,
    version=result.version,
    stage="Production"
)
print(f"Model version {result.version} moved to Production")
OutputSuccess
Common Mistakes
Skipping the staging step and moving models directly to production.
This can cause untested or low-quality models to be used in real applications, risking errors.
Always move models to 'Staging' first for testing and review before approving them to 'Production'.
Not specifying the correct model version when transitioning stages.
You might accidentally approve or reject the wrong model version.
Always check and specify the exact model version number when running transition commands.
Not listing model versions to verify their stages before deployment.
You may deploy an unapproved model or miss the latest approved version.
Use the list-versions command to confirm model stages before deployment.
Summary
Register your trained model to the model registry to track it.
Move the model to 'Staging' for testing and review before approval.
After approval, transition the model to 'Production' to mark it as ready for use.
Use commands to list model versions and their stages to keep track of approvals.

Practice

(1/5)
1. What is the main purpose of a model approval workflow in MLOps?
easy
A. To delete old models from storage
B. To train models faster using more data
C. To deploy models automatically without any checks
D. To check and approve machine learning models before they are used in production

Solution

  1. Step 1: Understand the role of model approval workflows

    Model approval workflows are designed to ensure models are reviewed and tested before use.
  2. Step 2: Identify the correct purpose

    The main goal is to check and approve models to keep production safe and reliable.
  3. Final Answer:

    To check and approve machine learning models before they are used in production -> Option D
  4. Quick Check:

    Model approval = safety check before use [OK]
Hint: Approval means checking before use, not training or deleting [OK]
Common Mistakes:
  • Confusing approval with training or deployment
  • Thinking approval deletes models
  • Assuming approval skips checks
2. Which of the following is the correct syntax to add a manual approval step in a typical MLOps pipeline YAML?
easy
A. steps: - approval_step: users: ['team_lead']
B. steps: - name: manual_approval type: approval inputs: approvers: ['team_lead']
C. steps: - manual_approval: approvers: 'team_lead'
D. steps: - name: approval type: manual approvers: team_lead

Solution

  1. Step 1: Review typical YAML structure for approval steps

    Approval steps usually have a name, type, and inputs including approvers as a list.
  2. Step 2: Match syntax with correct YAML format

    steps: - name: manual_approval type: approval inputs: approvers: ['team_lead'] correctly uses 'name', 'type', and 'inputs' with a list of approvers.
  3. Final Answer:

    steps: - name: manual_approval type: approval inputs: approvers: ['team_lead'] -> Option B
  4. Quick Check:

    Correct YAML keys and list format = steps: - name: manual_approval type: approval inputs: approvers: ['team_lead'] [OK]
Hint: Look for 'name', 'type', and list of approvers in YAML [OK]
Common Mistakes:
  • Using wrong keys like 'users' instead of 'approvers'
  • Not using list format for approvers
  • Incorrect indentation or missing 'type'
3. Given this simplified MLOps pipeline snippet, what will be the output status after running the approval step if the approver rejects the model?
steps:
  - name: train_model
    type: training
  - name: approve_model
    type: approval
    inputs:
      approvers: ['alice']
    on_reject: fail_pipeline
medium
A. Pipeline skips approval and deploys
B. Pipeline continues to deploy the model
C. Pipeline fails and stops immediately
D. Pipeline retries training automatically

Solution

  1. Step 1: Understand the approval step behavior

    The approval step waits for 'alice' to approve or reject the model.
  2. Step 2: Analyze the 'on_reject' action

    If rejected, the pipeline is set to 'fail_pipeline', which stops the process immediately.
  3. Final Answer:

    Pipeline fails and stops immediately -> Option C
  4. Quick Check:

    Reject triggers fail_pipeline = stop [OK]
Hint: 'on_reject: fail_pipeline' means stop on rejection [OK]
Common Mistakes:
  • Assuming pipeline continues after rejection
  • Thinking approval is skipped
  • Believing training retries automatically
4. You have this approval step configuration but the pipeline never pauses for approval. What is the likely error?
steps:
  - name: approve_model
    type: approval
    inputs:
      approvers: 'bob'
medium
A. Approvers should be a list, not a string
B. Missing 'type' field for approval step
C. Approval step name must be 'manual_approval'
D. Pipeline needs a trigger to pause

Solution

  1. Step 1: Check the 'approvers' format

    The 'approvers' field must be a list, e.g., ['bob'], not a plain string.
  2. Step 2: Understand impact of wrong format

    Using a string causes the pipeline to ignore the approval step or not pause.
  3. Final Answer:

    Approvers should be a list, not a string -> Option A
  4. Quick Check:

    Approvers list format required = Approvers should be a list, not a string [OK]
Hint: Approvers must be a list, even if one person [OK]
Common Mistakes:
  • Using string instead of list for approvers
  • Changing step name unnecessarily
  • Assuming pipeline triggers control pause
5. You want to create a model approval workflow that automatically approves models with accuracy above 90%, but requires manual approval otherwise. Which workflow design achieves this?
hard
A. Add an automatic test step checking accuracy, then a conditional approval step that auto-approves if accuracy > 90%, else manual approval
B. Only use manual approval for all models regardless of accuracy
C. Skip approval if accuracy is above 90%, else reject the model automatically
D. Deploy all models first, then ask for approval later

Solution

  1. Step 1: Define automatic test for accuracy

    Use a test step to check if model accuracy is above 90% automatically.
  2. Step 2: Set conditional approval based on test result

    If accuracy > 90%, auto-approve; otherwise, require manual approval to ensure safety.
  3. Final Answer:

    Add an automatic test step checking accuracy, then a conditional approval step that auto-approves if accuracy > 90%, else manual approval -> Option A
  4. Quick Check:

    Auto test + conditional approval = Add an automatic test step checking accuracy, then a conditional approval step that auto-approves if accuracy > 90%, else manual approval [OK]
Hint: Combine auto test with conditional manual approval [OK]
Common Mistakes:
  • Skipping manual approval for low accuracy models
  • Approving all models without checks
  • Approving after deployment instead of before