Overview
This tutorial walks you through a complete DVC workflow:- Initialize DVC in a Git repository
- Track datasets with version control
- Build a reproducible ML pipeline
- Set up remote storage and share data
This tutorial takes about 10 minutes. You’ll create a simple ML project that trains a model, tracks data and models, and pushes everything to remote storage.
Prerequisites
Before starting, ensure you have:1
Install DVC
Follow the installation guide to install DVC on your system.
2
Install Git
DVC works with Git repositories. Make sure Git is installed:
3
Python Environment
You’ll need Python 3.9+ for this tutorial. We’ll use basic Python scripts.
Step 1: Initialize a DVC Project
Start by creating a new project and initializing Git and DVC:What just happened?
What just happened?
The
dvc init command created:.dvc/directory with configuration and cache.dvc/.gitignoreto exclude cache from Git.dvc/configfor DVC settings.dvcignorefor files DVC should ignore
DVC has enabled anonymous usage analytics by default. This helps improve the tool. You can opt out anytime by running
dvc config core.analytics false. See analytics documentation for details.Step 2: Track Your First Dataset
Let’s create a sample dataset and track it with DVC:data/train.csv.dvc— metadata file tracked by Gitdata/.gitignore— tells Git to ignore the actual data file
Step 3: Create Training Scripts
Create simple training and preprocessing scripts:Create preprocess.py
preprocess.py
Create train.py
train.py
Install dependencies
Step 4: Build a DVC Pipeline
Instead of running scripts manually, create a DVC pipeline that tracks dependencies:Understanding the flags
Understanding the flags
-n— Name of the stage-d— Dependencies (if any change, stage will rerun)-o— Outputs (tracked by DVC)-M— Metrics file (tracked but not cached)
dvc.yaml file defining your pipeline:
Step 5: Run the Pipeline
Execute your pipeline with a single command:- Analyze dependencies
- Run stages in the correct order
- Track outputs
- Create
dvc.lockwith exact versions
Step 6: Make Changes and Reproduce
Let’s modify the training script and see DVC’s smart caching:DVC only reruns the
train stage because preprocess hasn’t changed. This saves time on long-running pipelines.Step 7: Set Up Remote Storage
To share data with your team, configure remote storage. DVC supports many storage types:- Local Remote (for testing)
- AWS S3
- Google Cloud Storage
- Azure Blob Storage
- SSH/SFTP
View remote configuration
View remote configuration
Check your Output:
.dvc/config file:Step 8: Push Data to Remote
Upload your data and models to remote storage:data/train.csvdata/processed.csvmodel.pkl
Step 9: Simulate Collaboration
Let’s see how a teammate would use your project:- View the exact data you used
- Reproduce your results with
dvc repro - Make their own changes
The
dvc pull command downloads data based on .dvc files in the current Git commit. This ensures everyone works with consistent data versions.Step 10: Track Experiments
DVC includes built-in experiment tracking:Common Workflows
Updating Data
When your dataset changes:Checking Status
See what’s changed:Comparing Data Versions
View differences between commits:What’s Next?
You’ve learned the core DVC workflow! Explore more:Core Concepts
Deep dive into how DVC works internally.
Command Reference
Explore all available DVC commands.
Building Pipelines
Learn advanced pipeline features and best practices.
Running Experiments
Master experiment tracking and comparison.
Remote Storage Guide
Configure and optimize remote storage.
Python API
Use DVC programmatically in your scripts.
Summary
In this tutorial, you:1
Initialized DVC
Set up DVC in a Git repository with
dvc init2
Tracked Data
Versioned datasets using
dvc add3
Built a Pipeline
Created reproducible stages with
dvc stage add4
Ran the Pipeline
Executed and reproduced results with
dvc repro5
Configured Remote
Set up remote storage with
dvc remote add6
Shared Data
Pushed data to remote with
dvc push7
Collaborated
Pulled data on another machine with
dvc pull