Provide a Python data science project boilerplate using DVC for data version control. Large datasets should be stored in S3/GCS with only .dvc metadata in Git. Include a dvc.yaml pipeline that reproduces training steps.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
The plan is to craft a minimal data science project skeleton using DVC with an S3/GCS remote and a multi-stage pipeline including preprocessing, training, and evaluation, plus sample config files like params.yaml, .gitignore, and requirements.txt. I'll include example pipeline YAML and succinct code snippets for each stage to clearly show how data, outputs, and params are wired.
Below is a minimal boilerplate for a Python data science project that uses DVC to version data and pipelines. Large datasets are stored in a cloud remote (S3 or GCS), while only small metadata files (like *.dvc, dvc.yaml, etc.) are tracked in Git.
# Ignore data and model artifacts; DVC will handle them
/data/
/models/
*.pkl
*.log
# Byte-compiled / cache
__pycache__/
*.py[cod]
# Virtual environment
.venv/
.env/
Example requirements.txt
txt
pandas
scikit-learn
numpy
pyyaml
# Install DVC with the extra matching your cloud backend:
dvc[s3] # For AWS S3
# or
dvc[gcs] # For Google Cloud Storage
This defines the pipeline to preprocess data, train a model, and evaluate it. DVC will track dependencies (deps), outputs (outs), parameters (params), and metrics.
dvc push
# pushes tracked data (data/raw, data/processed, models, etc.) to S3/GCS
Reproduce the pipeline:
bash
dvc repro
# or run the pipeline stage-by-stage
Fetch data for a fresh clone:
bash
git clone <repo>
cd <repo>
dvc pull # pulls data from S3/GCS remote based on .dvc metadata
README.md (Example)
md
# My DS Project (DVC-enabled)
This project shows how to set up a reproducible ML pipeline using DVC to track data and models separately from Git.
## Quickstart
1. Install dependencies:
pip install -r requirements.txt
code
2. Configure your DVC remote (S3 or GCS) in `.dvc/config`:
3. Pull data (if the remote already has the data):
dvc pull
code
4. Run the pipeline:
dvc repro
code
## Project Structure
- `data/`: raw and processed data (tracked by DVC, gitignored).
- `models/`: trained models (tracked by DVC, gitignored).
- `src/`: source code for preprocessing, training, evaluation.
- `dvc.yaml`: pipeline definition.
- `params.yaml`: hyperparameters.
## Notes
- Large files are *not* committed to Git. Only the small `.dvc` files and pipeline configs go into Git.
- To change data or hyperparameters, update `data/raw/...` or `params.yaml`, then re-run `dvc repro`.
- Use `dvc push` to upload new data/model artifacts to the configured remote.
This boilerplate keeps large datasets and models in S3/GCS via DVC, while only small metadata (.dvc files, pipeline configs, and code) are stored in Git. Adjust scripts, parameters, and pipeline stages as needed for your specific project.