Bird
Raised Fist0
MLOpsdevops~10 mins

Pipeline scheduling and triggers in MLOps - Interactive Code Practice

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
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to schedule a pipeline to run every day at midnight.

MLOps
schedule: cron: "[1]"
Drag options to blanks, or click blank then click option'
A0 0 * * 0
B0 12 * * *
C0 0 * * *
D0 6 * * *
Attempts:
3 left
💡 Hint
Common Mistakes
Using 12 instead of 0 for hour runs at noon, not midnight.
Setting day of week to 0 runs only on Sundays.
2fill in blank
medium

Complete the code to trigger a pipeline when a new commit is pushed to the main branch.

MLOps
trigger:
  branches:
    include:
      - [1]
Drag options to blanks, or click blank then click option'
Amain
Bdevelop
Cfeature
Drelease
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'develop' triggers on the wrong branch.
Using 'feature' triggers only feature branches.
3fill in blank
hard

Fix the error in the pipeline trigger to run only on tags starting with 'v'.

MLOps
trigger:
  tags:
    include:
      - [1]
Drag options to blanks, or click blank then click option'
A*v
Bv*
Cv
Dversion*
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'v' matches only the tag named exactly 'v'.
Using '*v' matches tags ending with 'v', not starting.
4fill in blank
hard

Fill both blanks to schedule a pipeline to run every 15 minutes only on weekdays.

MLOps
schedule:
  cron: "[1] [2] * * 1-5"
Drag options to blanks, or click blank then click option'
A*/15
B0
C*/5
D30
Attempts:
3 left
💡 Hint
Common Mistakes
Using '*/5' runs every 5 minutes, not 15.
Using '30' runs only at 30 minutes past the hour.
5fill in blank
hard

Fill all three blanks to define a pipeline trigger that runs on pushes to the 'dev' branch, on tags starting with 'release', and on a schedule every Sunday at 3 AM.

MLOps
trigger:
  branches:
    include:
      - [1]
  tags:
    include:
      - [2]
schedule:
  cron: "[3] 3 * * 0"
Drag options to blanks, or click blank then click option'
Adev
Brelease*
C0
Dmain
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'main' instead of 'dev' triggers on the wrong branch.
Using 'release' without '*' matches only exact tag 'release'.
Setting minute to '3' runs at 3 minutes past the hour, not 3 AM.

Practice

(1/5)
1. What is the main purpose of pipeline scheduling in MLOps?
easy
A. To store pipeline logs for debugging
B. To manually start pipelines whenever needed
C. To run tasks automatically at specific times without manual intervention
D. To create new machine learning models from scratch

Solution

  1. 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.
  2. 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.
  3. Final Answer:

    To run tasks automatically at specific times without manual intervention -> Option C
  4. Quick Check:

    Pipeline scheduling = automatic timed runs [OK]
Hint: Scheduling means automatic runs at set times [OK]
Common Mistakes:
  • Confusing scheduling with manual triggering
  • Thinking scheduling stores logs
  • Assuming scheduling creates models directly
2. Which of the following is a correct cron expression to schedule a pipeline to run every day at 3 AM?
easy
A. 3 0 * * *
B. 0 3 * * *
C. * 3 * * *
D. 0 0 3 * * *

Solution

  1. 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 (*).
  2. Step 2: Match expression

    0 3 * * * "0 3 * * *" means minute 0, hour 3, every day. Others have wrong order or extra fields.
  3. Final Answer:

    0 3 * * * -> Option B
  4. Quick Check:

    Minute=0, Hour=3 daily = 0 3 * * * [OK]
Hint: Cron: minute hour day month weekday; 3 AM is '0 3 * * *' [OK]
Common Mistakes:
  • Swapping hour and minute fields
  • Adding extra fields in cron
  • Using '*' in wrong positions
3. Given this pipeline trigger configuration snippet:
{
  "trigger": {
    "event": "data_arrival",
    "filter": {
      "file_type": "csv"
    }
  }
}

What happens when a new JSON file arrives in the data folder?
medium
A. The pipeline does not run because the file type is not CSV
B. The pipeline runs because any new file triggers it
C. The pipeline runs only if the JSON file is large
D. The pipeline runs but ignores the file type

Solution

  1. Step 1: Analyze trigger filter

    The trigger listens for 'data_arrival' events but only runs if the file type is 'csv'.
  2. Step 2: Apply to JSON file

    A JSON file does not match the 'csv' filter, so the pipeline will not run.
  3. Final Answer:

    The pipeline does not run because the file type is not CSV -> Option A
  4. Quick Check:

    Filter file_type=csv blocks JSON files [OK]
Hint: Triggers with filters run only on matching events [OK]
Common Mistakes:
  • Ignoring filter conditions
  • Assuming any file triggers pipeline
  • Confusing event type with file type
4. You wrote this cron expression to schedule a pipeline every hour:
60 * * * *

Why does the pipeline never run?
medium
A. Because the hour field is missing
B. Because cron requires seconds field
C. Because the asterisks are misplaced
D. Because 60 is not a valid minute value in cron syntax

Solution

  1. Step 1: Check minute field validity

    Cron minute values must be 0-59. '60' is invalid and causes no runs.
  2. Step 2: Confirm other fields

    The hour and other fields are correct as '*', meaning every hour/day. The error is only the minute value.
  3. Final Answer:

    Because 60 is not a valid minute value in cron syntax -> Option D
  4. Quick Check:

    Minute must be 0-59; 60 is invalid [OK]
Hint: Minutes in cron go 0-59, never 60 [OK]
Common Mistakes:
  • Using 60 as minute value
  • Thinking cron needs seconds field
  • Misplacing asterisks
5. You want a pipeline to run automatically when new data arrives and also every Sunday at midnight. Which setup correctly combines scheduling and event triggers?
hard
A. Use a cron schedule '0 0 * * 0' and an event trigger for 'data_arrival' together
B. Use only a cron schedule '0 0 * * 0' because event triggers conflict with schedules
C. Use only an event trigger for 'data_arrival' and manually run on Sundays
D. Use a cron schedule '0 0 * * 7' and ignore event triggers

Solution

  1. Step 1: Understand combined triggers

    Pipelines can have both cron schedules and event triggers to run on different conditions.
  2. 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).
  3. Step 3: Confirm event trigger for data arrival

    Adding an event trigger for 'data_arrival' ensures pipeline runs when new data arrives.
  4. Final Answer:

    Use a cron schedule '0 0 * * 0' and an event trigger for 'data_arrival' together -> Option A
  5. Quick Check:

    Combine cron and event triggers for full automation [OK]
Hint: Combine cron and event triggers for multiple run conditions [OK]
Common Mistakes:
  • Thinking schedules and triggers cannot coexist
  • Using wrong cron day for Sunday
  • Ignoring event triggers for data arrival