Challenge - 5 Problems
MLflow Artifact & Model Logging Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2: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)
Attempts:
2 left
💡 Hint
The artifact_uri shows the local path where artifacts are stored during the run.
✗ Incorrect
MLflow stores artifacts locally by default under the mlruns directory. The artifact_uri attribute gives the local file path for the current run's artifacts.
🧠 Conceptual
intermediate1: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?
Attempts:
2 left
💡 Hint
Logging a model uses a specific MLflow flavor function.
✗ Incorrect
mlflow.sklearn.log_model saves the model in a format MLflow can use for deployment. log_artifact is for files, log_param and log_metric are for parameters and metrics.
❓ Troubleshoot
advanced2: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
Attempts:
2 left
💡 Hint
Check when the file is created relative to when it is logged.
✗ Incorrect
MLflow cannot log a file that does not exist at the time log_artifact is called. The file must be created before logging.
🔀 Workflow
advanced3: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.
Attempts:
2 left
💡 Hint
You must start the run before logging anything.
✗ Incorrect
The correct workflow is to start the run, train the model, log the model, log metrics, then end the run.
✅ Best Practice
expert2: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?
Attempts:
2 left
💡 Hint
MLflow provides a built-in system for model versioning.
✗ Incorrect
MLflow Model Registry is designed to manage model versions, stages, and metadata centrally. Manual renaming or external storage is error-prone.