An end-to-end red-wine quality prediction project built with ElasticNet, DVC, DagsHub, MLflow, and Flask.
Ingestion → Validation → Transformation → Training → Evaluation
DVC versions the generated datasets, model, and metrics. DagsHub provides the DVC remote and MLflow experiment tracking.
conda create --prefix ./venv python=3.11 -y
conda activate ./venv
python -m pip install -r requirements.txt
python -m pip install -e .For an existing clone, restore the DVC-managed artifacts:
dvc pullsetup.py defines the installable winequality package and its dependencies.
Because the source code uses a src/ layout, install the project in editable
mode during development:
python -m pip install -e .This makes winequality imports available while keeping code changes
immediately visible without reinstalling the package. The command may create a
local *.egg-info/ metadata directory; this is expected and should remain
excluded from Git.
The repository already contains dvc.yaml; it normally does not need to be
generated again. To recreate it from scratch, remove the existing stages and
run the following commands from the project root.
dvc stage add -n ingestion `
-d main.py -d config/config.yaml `
-d src/winequality/components/data_ingestion.py `
-d src/winequality/pipeline/data_ingestion_pipeline.py `
-o artifacts/data_ingestion/data.zip `
-o artifacts/data_ingestion/winequality-red.csv `
"python main.py --stages ingestion"dvc stage add -n validation `
-d main.py -d config/config.yaml -d schema.yaml `
-d artifacts/data_ingestion/winequality-red.csv `
-d src/winequality/components/data_validation.py `
-d src/winequality/pipeline/data_validation_pipeline.py `
-o artifacts/data_validation/status.txt `
"python main.py --stages validation"dvc stage add -n transformation `
-d main.py -d config/config.yaml `
-d artifacts/data_ingestion/winequality-red.csv `
-d artifacts/data_validation/status.txt `
-d src/winequality/components/data_transformation.py `
-d src/winequality/pipeline/data_transformation_pipeline.py `
-o artifacts/data_transformation/train.csv `
-o artifacts/data_transformation/test.csv `
"python main.py --stages transformation"dvc stage add -n training `
-d main.py -d config/config.yaml -d schema.yaml `
-d artifacts/data_transformation/train.csv `
-d artifacts/data_transformation/test.csv `
-d src/winequality/components/model_trainer.py `
-d src/winequality/pipeline/model_trainer_pipeline.py `
-p ElasticNet.alpha -p ElasticNet.l1_ratio `
-o artifacts/model_trainer/model.joblib `
"python main.py --stages training"dvc stage add -n evaluation `
-d main.py -d config/config.yaml -d schema.yaml `
-d artifacts/data_transformation/test.csv `
-d artifacts/model_trainer/model.joblib `
-d src/winequality/components/model_evaluation.py `
-d src/winequality/pipeline/model_evaluation_pipeline.py `
-p ElasticNet.alpha -p ElasticNet.l1_ratio `
-M artifacts/model_evaluation/metrics.json `
"python main.py --stages evaluation"Run and inspect the pipeline:
dvc repro
dvc dag
dvc metrics showPush the generated artifacts to the configured DagsHub remote:
dvc push
git add dvc.yaml dvc.lock params.yaml
git commit -m "Update DVC pipeline"
git pushThe artifacts/ directory is excluded from Git. DagsHub may still display its
files because DagsHub combines the Git repository with DVC-managed storage.
Run every stage:
python main.py --stages allRun one or more selected stages:
python main.py --stages ingestion
python main.py --stages ingestion validation transformationSupported stages are ingestion, validation, transformation, training,
and evaluation.
Use dvc repro when DVC caching and artifact versioning are required.
Start the application:
python app.pyOpen the prediction UI at http://127.0.0.1:8080.
Deployment endpoints:
| Environment | URL |
|---|---|
| Local | http://127.0.0.1:8080 |
| Render | https://wine-quality-prediction-latest.onrender.com/ |
This project supports local, Docker, and cloud deployments.
For detailed step-by-step deployment instructions, including:
- Docker image creation
- GitHub Container Registry (GHCR)
- GitHub Actions CI/CD
- Render Web Service deployment
- Azure Container Registry (ACR)
- Azure Web App deployment
- Troubleshooting common deployment issues
refer to the deployment guide maintained in the companion repository:
https://github.com/ashes-github/mlproject-main
The deployment workflow documented there can be reused for this project with only minor configuration changes (repository name, image name, environment variables, and model artifacts).
The image includes the trained model at
artifacts/model_trainer/model.joblib, so it can serve predictions immediately.
The local .env file is never copied into the image; it is supplied only at
container runtime for DagsHub/MLflow access during training.
Build and run with Docker Compose:
docker compose up --buildOpen the prediction UI at http://127.0.0.1:8080. The Compose configuration
mounts artifacts/ and logs/ so models produced by /train and application
logs persist on the host. Stop the application with Ctrl+C and remove its
container with:
docker compose downTo run the image without Compose (for prediction-only use), pass MLflow credentials only if you intend to call a training endpoint:
docker build -t winequalityprediction .
docker run --rm -p 8080:8080 winequalitypredictionRun the complete training pipeline:
Invoke-RestMethod -Method Post -Uri "http://127.0.0.1:8080/train"Run one stage:
Invoke-RestMethod -Method Post -Uri "http://127.0.0.1:8080/train/training"Run selected stages:
$body = @{ stages = @("ingestion", "validation") } | ConvertTo-Json
Invoke-RestMethod `
-Method Post `
-Uri "http://127.0.0.1:8080/train" `
-ContentType "application/json" `
-Body $bodyThe Flask training endpoints call the Python pipeline directly; they do not run
dvc repro.
Note
When deploying to Render, the application listens on the port supplied by the
PORTenvironment variable. Logs are written to standard output (and optionally/tmp/logs) to comply with container filesystem permissions.
Set these values locally or through CI secrets:
MLFLOW_TRACKING_URI=https://dagshub.com/<owner>/<repository>.mlflow
MLFLOW_TRACKING_USERNAME=<owner>
MLFLOW_TRACKING_PASSWORD=<DagsHub access token>
Never commit credentials or the local .env file.
This project can be deployed using GitHub Actions.
A typical deployment workflow is:
Git Push
│
▼
GitHub Actions
│
▼
Build Docker Image
│
▼
Publish to GitHub Container Registry (GHCR)
│
▼
Trigger Render Deployment
When adding or modifying a pipeline stage, follow this order:
- Update
config/config.yaml. - Update
schema.yaml, if the data schema changes. - Update
params.yaml, if model parameters change. - Update the entity in
src/winequality/entity. - Update the configuration manager in
src/winequality/config. - Update the component in
src/winequality/components. - Update the pipeline wrapper in
src/winequality/pipeline. - Update the stage registration in
main.py. - Update the corresponding dependencies, parameters, and outputs in
dvc.yaml. - Run
dvc reproand commit the updateddvc.lock.