Pipeline scheduling and triggers in MLOps - Time & Space Complexity
Start learning this pattern below
Jump into concepts and practice - no test required
We want to understand how the time to start and run pipelines changes as we add more schedules or triggers.
How does the system handle more triggers and what happens to the execution time?
Analyze the time complexity of the following pipeline scheduling code.
for trigger in pipeline_triggers:
if trigger.condition_met():
pipeline.run(trigger.parameters)
This code checks each trigger condition and runs the pipeline if the condition is true.
Look for loops or repeated checks.
- Primary operation: Checking each trigger's condition.
- How many times: Once for each trigger in the list.
As the number of triggers grows, the system checks more conditions one by one.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 | 10 condition checks |
| 100 | 100 condition checks |
| 1000 | 1000 condition checks |
Pattern observation: The number of checks grows directly with the number of triggers.
Time Complexity: O(n)
This means the time to check triggers grows linearly as you add more triggers.
[X] Wrong: "Adding more triggers won't affect the pipeline start time much."
[OK] Correct: Each trigger adds a condition check, so more triggers mean more time spent checking before running.
Understanding how pipeline triggers scale helps you design efficient automation that stays fast as it grows.
"What if we batch triggers to check conditions together? How would that change the time complexity?"
Practice
Solution
Step 1: Understand pipeline scheduling
Pipeline scheduling is designed to run tasks automatically at set times, like daily or hourly, without needing a person to start them.Step 2: Compare options
Only To run tasks automatically at specific times without manual intervention describes automatic running at specific times. Other options describe manual actions or unrelated tasks.Final Answer:
To run tasks automatically at specific times without manual intervention -> Option CQuick Check:
Pipeline scheduling = automatic timed runs [OK]
- Confusing scheduling with manual triggering
- Thinking scheduling stores logs
- Assuming scheduling creates models directly
Solution
Step 1: Understand cron format
Cron syntax is: minute hour day month weekday. To run at 3 AM daily, minute=0, hour=3, day/month/weekday=any (*).Step 2: Match expression
0 3 * * * "0 3 * * *" means minute 0, hour 3, every day. Others have wrong order or extra fields.Final Answer:
0 3 * * * -> Option BQuick Check:
Minute=0, Hour=3 daily = 0 3 * * * [OK]
- Swapping hour and minute fields
- Adding extra fields in cron
- Using '*' in wrong positions
{
"trigger": {
"event": "data_arrival",
"filter": {
"file_type": "csv"
}
}
}What happens when a new JSON file arrives in the data folder?
Solution
Step 1: Analyze trigger filter
The trigger listens for 'data_arrival' events but only runs if the file type is 'csv'.Step 2: Apply to JSON file
A JSON file does not match the 'csv' filter, so the pipeline will not run.Final Answer:
The pipeline does not run because the file type is not CSV -> Option AQuick Check:
Filter file_type=csv blocks JSON files [OK]
- Ignoring filter conditions
- Assuming any file triggers pipeline
- Confusing event type with file type
60 * * * *
Why does the pipeline never run?
Solution
Step 1: Check minute field validity
Cron minute values must be 0-59. '60' is invalid and causes no runs.Step 2: Confirm other fields
The hour and other fields are correct as '*', meaning every hour/day. The error is only the minute value.Final Answer:
Because 60 is not a valid minute value in cron syntax -> Option DQuick Check:
Minute must be 0-59; 60 is invalid [OK]
- Using 60 as minute value
- Thinking cron needs seconds field
- Misplacing asterisks
Solution
Step 1: Understand combined triggers
Pipelines can have both cron schedules and event triggers to run on different conditions.Step 2: Verify cron expression for Sunday midnight
'0 0 * * 0' runs at midnight on Sundays (0 or 7 can represent Sunday, but 0 is standard).Step 3: Confirm event trigger for data arrival
Adding an event trigger for 'data_arrival' ensures pipeline runs when new data arrives.Final Answer:
Use a cron schedule '0 0 * * 0' and an event trigger for 'data_arrival' together -> Option AQuick Check:
Combine cron and event triggers for full automation [OK]
- Thinking schedules and triggers cannot coexist
- Using wrong cron day for Sunday
- Ignoring event triggers for data arrival
