This page documents the most common mistakes students make in the MLOps Fundamentals Homework and exactly how to fix them. Work through these before opening your PR — each pitfall below has caused students to lose points that were otherwise within reach.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/characat0/mlops-fundamentals-homework/llms.txt
Use this file to discover all available pages before exploring further.
Off-by-one in the temporal split
Off-by-one in the temporal split
Year 2010 must go to the training set (The test
year <= 2010), not to the production set. The single most common mistake is using a strict less-than (year < 2010), which silently misassigns every 2010 row to the production split.test_process_data_year_boundary_condition specifically checks this boundary condition. If it fails, this is the first thing to verify.Forgetting to encode genre labels
Forgetting to encode genre labels
scikit-learn models require numeric targets. Passing raw string genre values (e.g., Keep the fitted
'Rock', 'Pop') directly to .fit() raises a ValueError. You must encode the labels with LabelEncoder before fitting any model.le object — you will need it to decode numeric predictions back to genre strings when the API returns results.Missing MLflow logging — parameters or metrics not logged
Missing MLflow logging — parameters or metrics not logged
If you train a model without an active Then navigate to
mlflow.start_run() context, the run is recorded in the default experiment but carries no parameters, no metrics, and no model artifact. evaluate.py may still find the run, but graders check the MLflow UI explicitly for proper run naming and logged values.Open the UI and confirm each run shows:- The model’s hyperparameters (e.g.,
Cfor Logistic Regression,max_depthfor XGBoost) - An
accuracymetric - A logged model artifact
http://localhost:5000 and confirm both the Logistic Regression and XGBoost runs appear with all expected values before running evaluate.py.Pydantic field mismatches in SpotifyFeatures
Pydantic field mismatches in SpotifyFeatures
The test payload in
Pay special attention to
test_api.py sends exactly 12 fields. If SpotifyFeatures is missing any field, has an extra field with a different name, or uses a wrong type (e.g., duration_ms as float instead of int), the endpoint returns 422 Unprocessable Entity instead of 200 OK and the test fails.The exact fields and types that must match:| Field | Type |
|---|---|
danceability | float |
energy | float |
key | int |
loudness | float |
mode | int |
speechiness | float |
acousticness | float |
instrumentalness | float |
liveness | float |
valence | float |
tempo | float |
duration_ms | int |
key, mode, and duration_ms — these are integers, not floats.Docker build fails — model not registered
Docker build fails — model not registered
The If the build fails with “Connection refused”, the MLflow server is not running or is not accessible from the Docker build context.
RUN mlflow models download step in the Dockerfile requires two things to be true at build time:- The MLflow tracking server must be reachable from the machine running
docker build. - The
spotify-genre-classifiermodel must already have a@championalias registered in the Model Registry.
- Run
dvc reproindata_pipeline/to execute the full training pipeline. - Open the MLflow UI at
http://localhost:5000and verify the champion alias is assigned. - Only then run
docker build.
Git not tracking all files — CI fails with import errors
Git not tracking all files — CI fails with import errors
If you create new files (e.g., a utility module or helper script) but forget to
git add them, those files exist locally but are invisible to CI. The result is an ImportError or ModuleNotFoundError in the Actions run even though all tests pass on your machine.Always run git status before pushing to verify every changed or new file is staged:flake8 E501 — line too long
flake8 E501 — line too long
By default, flake8 flags lines longer than 79 characters as Option 2 — suppress the warning on a specific line where breaking would hurt readability:Run
E501. Long lines most commonly appear in MLflow logging calls, dictionary literals, and URL strings. There are two clean ways to handle this:Option 1 — use Python’s implicit line continuation inside parentheses:flake8 . locally before every push — it runs in under a second and shows you exactly which lines to fix.MLflow experiment is None in evaluate.py
MLflow experiment is None in evaluate.py
evaluate.py calls client.get_experiment_by_name(experiment_name) to find the runs from training. This returns None if no experiment with that name exists — which happens when train.py uses a different experiment name or never calls mlflow.set_experiment() at all and falls back to the default experiment (ID "0").To fix this, ensure the experiment name is consistent between train.py and evaluate.py:evaluate.py to fall back to client.get_experiment("0") when the named lookup returns None.If CI is failing but you cannot reproduce the error locally, paste the full GitHub Actions log into your PR description when asking for help. Sharing only the final error line makes it much harder for instructors to diagnose the root cause.