0
0
MLOpsdevops~20 mins

Logging artifacts and models in MLOps - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
MLflow Artifact & Model Logging Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of this MLflow artifact logging command?
Consider the following Python code snippet using MLflow to log an artifact file. What will be the output printed after running this code?
MLOps
import mlflow
with open('model_info.txt', 'w') as f:
    f.write('Model version 1.0')
with mlflow.start_run() as run:
    mlflow.log_artifact('model_info.txt')
    print(run.info.artifact_uri)
Afile:///path/to/mlruns/0/<run_id>/artifacts
Bs3://mlflow-bucket/artifacts/<run_id>
Chttp://localhost:5000/api/2.0/mlflow/artifacts/<run_id>
DError: artifact_uri attribute not found
Attempts:
2 left
💡 Hint
The artifact_uri shows the local path where artifacts are stored during the run.
🧠 Conceptual
intermediate
1:30remaining
Which MLflow command logs a model for later deployment?
You want to save a trained scikit-learn model in MLflow so it can be deployed later. Which command correctly logs the model?
Amlflow.log_metric('model', model)
Bmlflow.sklearn.log_model(model, 'model')
Cmlflow.log_param('model', model)
Dmlflow.log_artifact(model, 'model')
Attempts:
2 left
💡 Hint
Logging a model uses a specific MLflow flavor function.
Troubleshoot
advanced
2:30remaining
Why does MLflow fail to log artifacts in this code?
You run this code but no artifacts appear in the MLflow UI. What is the most likely cause?
MLOps
import mlflow
with mlflow.start_run():
    mlflow.log_artifact('output.txt')
# output.txt is created after the run block
AThe artifact file does not exist when log_artifact is called
Boutput.txt must be a directory, not a file
Clog_artifact only works outside the run context
DMLflow requires explicit run ID to log artifacts
Attempts:
2 left
💡 Hint
Check when the file is created relative to when it is logged.
🔀 Workflow
advanced
3:00remaining
Order the steps to log a model and its metrics in MLflow
Arrange these steps in the correct order to log a model and its evaluation metrics using MLflow.
A1,3,2,4,5
B1,2,3,4,5
C2,1,4,3,5
D2,1,3,4,5
Attempts:
2 left
💡 Hint
You must start the run before logging anything.
Best Practice
expert
2:00remaining
What is the best practice for versioning models in MLflow?
You want to keep track of multiple versions of your models in MLflow for easy rollback and comparison. Which approach is best?
AStore models in separate folders outside MLflow
BManually rename model files with version numbers before logging
CUse MLflow Model Registry to register and version models
DLog models without versioning and rely on timestamps
Attempts:
2 left
💡 Hint
MLflow provides a built-in system for model versioning.