Bird
Raised Fist0
ML Pythonml~20 mins

CI/CD for ML pipelines in ML Python - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
ML CI/CD Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding CI/CD stages in ML pipelines

Which stage in a CI/CD pipeline for ML is responsible for automatically retraining the model when new data arrives?

AModel deployment stage
BContinuous training stage
CContinuous integration stage
DMonitoring stage
Attempts:
2 left
💡 Hint

Think about which stage updates the model with fresh data.

💻 Command Output
intermediate
2:00remaining
Output of a pipeline status command

What is the output of the command mlflow pipelines status --pipeline-name churn-prediction if the pipeline is currently running?

ML Python
mlflow pipelines status --pipeline-name churn-prediction
APipeline 'churn-prediction' status: RUNNING
BError: Pipeline not found
CPipeline 'churn-prediction' status: FAILED
DNo pipelines currently running
Attempts:
2 left
💡 Hint

Look for the status message indicating the pipeline is active.

❓ Configuration
advanced
2:00remaining
Correct YAML snippet for triggering retraining

Which YAML snippet correctly configures a GitHub Actions workflow to trigger model retraining on every push to the main branch?

ML Python
name: ML Retrain
on:
  push:
    branches:
      - main
jobs:
  retrain:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Run retrain script
        run: python retrain.py
A
on:
  schedule:
    - cron: '0 0 * * *'
B
on:
  pull_request:
    branches:
      - main
C
on:
  push:
    branches:
      - main
D
on:
  push:
    tags:
      - main
Attempts:
2 left
💡 Hint

Look for the event that triggers on code push to the main branch.

❓ Troubleshoot
advanced
2:00remaining
Diagnosing failed model deployment

You have a CI/CD pipeline that builds and deploys an ML model. The build succeeds but deployment fails with the error: Permission denied: unable to push to model registry. What is the most likely cause?

AThe model artifact is missing from the build
BThe deployment script has a syntax error
CThe model registry service is down
DThe CI/CD pipeline lacks permissions to write to the model registry
Attempts:
2 left
💡 Hint

Consider access rights needed for deployment.

🔀 Workflow
expert
3:00remaining
Order of steps in a CI/CD ML pipeline

Arrange the following steps in the correct order for a typical CI/CD pipeline for ML models:

  1. Deploy model to production
  2. Run automated tests on model code
  3. Train model with new data
  4. Build model artifact
A1,2,3,4
B2,1,3,4
C1,3,2,4
D3,2,1,4
Attempts:
2 left
💡 Hint

Think about testing before training, then building, then deploying.

Practice

(1/5)
1. What is the main purpose of a CI/CD pipeline in machine learning projects?
easy
A. To manually update model parameters
B. To automate model training, testing, and deployment
C. To store large datasets only
D. To write machine learning algorithms from scratch

Solution

  1. Step 1: Understand CI/CD pipeline role

    CI/CD pipelines automate repetitive tasks like training, testing, and deploying ML models.
  2. Step 2: Compare options

    Only To automate model training, testing, and deployment describes automation of these tasks; others describe unrelated activities.
  3. Final Answer:

    To automate model training, testing, and deployment -> Option B
  4. Quick Check:

    CI/CD automates ML workflows = B [OK]
Hint: CI/CD means automating ML workflow steps [OK]
Common Mistakes:
  • Thinking CI/CD is only for code storage
  • Confusing manual updates with automation
  • Assuming CI/CD writes ML algorithms
2. Which of the following is the correct YAML syntax snippet to trigger a CI/CD pipeline on every code push in GitHub Actions?
easy
A. on: [push]
B. trigger: push
C. when: code_push
D. event: commit

Solution

  1. Step 1: Identify GitHub Actions trigger syntax

    GitHub Actions uses 'on:' keyword with event names like 'push' to trigger workflows.
  2. Step 2: Validate options

    Only 'on: [push]' is valid YAML syntax for triggering on code push.
  3. Final Answer:

    on: [push] -> Option A
  4. Quick Check:

    GitHub Actions trigger = on: [push] [OK]
Hint: GitHub Actions uses 'on:' for triggers [OK]
Common Mistakes:
  • Using 'trigger' instead of 'on'
  • Wrong keywords like 'when' or 'event'
  • Incorrect YAML list syntax
3. Given this simplified ML pipeline step in a CI/CD YAML file:
steps:
  - name: Train model
    run: python train.py --epochs 5
  - name: Test model
    run: python test.py
  - name: Deploy model
    run: python deploy.py

What will happen if train.py fails during execution?
medium
A. The pipeline stops and does not run test or deploy steps
B. The pipeline continues to test and deploy steps regardless
C. Only the deploy step is skipped, test runs
D. The pipeline retries the train step automatically

Solution

  1. Step 1: Understand default CI/CD step behavior

    By default, if a step fails, the pipeline stops and next steps do not run.
  2. Step 2: Apply to given steps

    If 'train.py' fails, 'test.py' and 'deploy.py' steps will not execute.
  3. Final Answer:

    The pipeline stops and does not run test or deploy steps -> Option A
  4. Quick Check:

    Step failure stops pipeline = A [OK]
Hint: Failed step stops pipeline unless configured otherwise [OK]
Common Mistakes:
  • Assuming pipeline continues after failure
  • Thinking only deploy step is skipped
  • Believing automatic retries happen by default
4. You wrote this GitHub Actions step to deploy your ML model:
- name: Deploy model
  run: python deploy.py
  if: success()

But the deploy step runs even if the test step fails. What is the likely cause?
medium
A. The deploy.py script always succeeds regardless of tests
B. The 'if' condition should be 'if: failure()' to run on failure
C. GitHub Actions ignores 'if' conditions on run steps
D. The 'if: success()' condition is incorrectly indented

Solution

  1. Step 1: Check YAML indentation rules

    In GitHub Actions, 'if:' must be at the same level as 'run:' to apply correctly.
  2. Step 2: Analyze given snippet

    'if: success()' is indented under 'run:', so it is ignored and deploy runs always.
  3. Final Answer:

    The 'if: success()' condition is incorrectly indented -> Option D
  4. Quick Check:

    YAML indentation affects condition execution = D [OK]
Hint: Check YAML indentation for 'if:' conditions [OK]
Common Mistakes:
  • Misplacing 'if:' under 'run:'
  • Confusing success() with failure()
  • Assuming scripts control step execution
5. You want to automate retraining your ML model weekly and also on every code push. Which CI/CD configuration best achieves this?
hard
A. trigger: push\nschedule: weekly\ncron: '0 0 * * 0'
B. on: push\nschedule: 'weekly' # invalid syntax
C. on: [push, schedule]\nschedule:\n - cron: '0 0 * * 0' # every Sunday midnight
D. on: [push]\nschedule: every Sunday

Solution

  1. Step 1: Understand GitHub Actions triggers

    To trigger on code push and schedule, use 'on:' with both 'push' and 'schedule' keys.
  2. Step 2: Validate cron syntax

    on: [push, schedule]\nschedule:\n - cron: '0 0 * * 0' # every Sunday midnight uses correct cron format for weekly schedule and valid YAML syntax.
  3. Final Answer:

    on: [push, schedule]\nschedule:\n - cron: '0 0 * * 0' # every Sunday midnight -> Option C
  4. Quick Check:

    Use 'on:' with push and schedule + valid cron [OK]
Hint: Use 'on:' with push and schedule plus cron for weekly [OK]
Common Mistakes:
  • Using invalid schedule syntax
  • Misplacing cron outside schedule
  • Using unsupported keywords like 'trigger'
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard