Model approval workflows in MLOps - Time & Space Complexity
Start learning this pattern below
Jump into concepts and practice - no test required
When managing machine learning models, approval workflows help decide which models are ready to use.
We want to know how the time to approve models changes as more models enter the workflow.
Analyze the time complexity of the following model approval process.
for model in model_list:
if evaluate_model(model):
approve_model(model)
else:
reject_model(model)
This code checks each model one by one, evaluates it, and then approves or rejects it.
Look for repeated actions in the code.
- Primary operation: Looping through each model in the list.
- How many times: Once for every model in the list.
As the number of models grows, the time to approve them grows too.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 | 10 evaluations and approvals/rejections |
| 100 | 100 evaluations and approvals/rejections |
| 1000 | 1000 evaluations and approvals/rejections |
Pattern observation: The work grows directly with the number of models.
Time Complexity: O(n)
This means the time to finish approval grows in a straight line as more models come in.
[X] Wrong: "Approving multiple models at once takes the same time as approving one."
[OK] Correct: Each model needs its own evaluation and decision, so more models mean more time.
Understanding how approval time grows helps you design workflows that scale well as your model collection grows.
What if we batch evaluate models instead of one by one? How would the time complexity change?
Practice
model approval workflow in MLOps?Solution
Step 1: Understand the role of model approval workflows
Model approval workflows are designed to ensure models are reviewed and tested before use.Step 2: Identify the correct purpose
The main goal is to check and approve models to keep production safe and reliable.Final Answer:
To check and approve machine learning models before they are used in production -> Option DQuick Check:
Model approval = safety check before use [OK]
- Confusing approval with training or deployment
- Thinking approval deletes models
- Assuming approval skips checks
Solution
Step 1: Review typical YAML structure for approval steps
Approval steps usually have a name, type, and inputs including approvers as a list.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.Final Answer:
steps: - name: manual_approval type: approval inputs: approvers: ['team_lead'] -> Option BQuick Check:
Correct YAML keys and list format = steps: - name: manual_approval type: approval inputs: approvers: ['team_lead'] [OK]
- Using wrong keys like 'users' instead of 'approvers'
- Not using list format for approvers
- Incorrect indentation or missing 'type'
steps:
- name: train_model
type: training
- name: approve_model
type: approval
inputs:
approvers: ['alice']
on_reject: fail_pipeline
Solution
Step 1: Understand the approval step behavior
The approval step waits for 'alice' to approve or reject the model.Step 2: Analyze the 'on_reject' action
If rejected, the pipeline is set to 'fail_pipeline', which stops the process immediately.Final Answer:
Pipeline fails and stops immediately -> Option CQuick Check:
Reject triggers fail_pipeline = stop [OK]
- Assuming pipeline continues after rejection
- Thinking approval is skipped
- Believing training retries automatically
steps:
- name: approve_model
type: approval
inputs:
approvers: 'bob'
Solution
Step 1: Check the 'approvers' format
The 'approvers' field must be a list, e.g., ['bob'], not a plain string.Step 2: Understand impact of wrong format
Using a string causes the pipeline to ignore the approval step or not pause.Final Answer:
Approvers should be a list, not a string -> Option AQuick Check:
Approvers list format required = Approvers should be a list, not a string [OK]
- Using string instead of list for approvers
- Changing step name unnecessarily
- Assuming pipeline triggers control pause
Solution
Step 1: Define automatic test for accuracy
Use a test step to check if model accuracy is above 90% automatically.Step 2: Set conditional approval based on test result
If accuracy > 90%, auto-approve; otherwise, require manual approval to ensure safety.Final Answer:
Add an automatic test step checking accuracy, then a conditional approval step that auto-approves if accuracy > 90%, else manual approval -> Option AQuick 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]
- Skipping manual approval for low accuracy models
- Approving all models without checks
- Approving after deployment instead of before
