0
0
MLOpsdevops~20 mins

Automated testing for ML code in MLOps - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
ML Testing Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Purpose of Unit Tests in ML Pipelines

Why are unit tests important in automated testing of machine learning code?

AThey verify individual components like data preprocessing and model functions work correctly in isolation.
BThey check the final model accuracy on the test dataset only.
CThey automate the deployment of ML models to production.
DThey replace the need for data validation and cleaning.
Attempts:
2 left
💡 Hint

Think about testing small parts separately before combining them.

💻 Command Output
intermediate
2:00remaining
Output of pytest on ML Test File

Given a test file test_model.py with 3 passing tests and 1 failing test, what is the typical pytest summary output?

MLOps
pytest test_model.py
A1 failed, 3 passed in 0.05s
B4 passed in 0.05s
C3 failed, 1 passed in 0.05s
DSyntaxError: invalid syntax in test_model.py
Attempts:
2 left
💡 Hint

Count how many tests passed and failed.

Configuration
advanced
2:00remaining
Correct pytest Configuration for ML Project

Which pytest.ini configuration correctly sets the test path to tests/ and adds markers for ML tests?

A
[pytest]
testpaths = tests
markers = ml - mark test as ML related
B
[pytest]
testpaths = src
markers = ml: mark test as ML related
C
[pytest]
testpaths = tests
markers = ml: mark test as ML related
D
[pytest]
testpaths = tests
markers =
  ml: mark test as ML related
Attempts:
2 left
💡 Hint

Look for correct syntax and indentation in ini files.

Troubleshoot
advanced
2:00remaining
Diagnosing Flaky ML Tests

ML tests sometimes pass and sometimes fail without code changes. What is the most likely cause?

AThe test code has syntax errors causing intermittent failures.
BTests depend on random seeds or external data sources without fixing randomness.
CThe ML model is overfitting the training data.
DThe CI/CD pipeline is not running tests at all.
Attempts:
2 left
💡 Hint

Think about what causes unpredictable test results.

🔀 Workflow
expert
3:00remaining
Best Workflow for Automated ML Testing in CI/CD

Which sequence correctly describes an automated ML testing workflow in a CI/CD pipeline?

A1,2,4,3
B2,1,3,4
C1,2,3,4
D1,3,2,4
Attempts:
2 left
💡 Hint

Think about logical order from code change to deployment.