Sub topic 12
Working in a team and in CI
Assume you know basic Git commands, can read YAML, and have already configured a DVC remote. This chapter shows how a team keeps Git history, DVC files, and shared data consistent. It also shows how continuous integration (CI) checks that a pipeline can be reproduced.
A team workflow
DVC does not replace Git. Git records the project files and the small pointer files that describe data and model outputs. The DVC remote stores the larger files. Each teammate needs access to both systems.
A typical change follows this sequence:
- Create a Git branch.
- Pull the current Git commits and DVC data.
- Change code, parameters, or data.
- Run the pipeline locally.
- Push new DVC objects to the shared remote.
- Commit
dvc.yaml,dvc.lock, parameter files, and pointer files to Git. - Open a pull request.
- Let CI reproduce or validate the pipeline.
The order of the final two data operations matters. Push the data objects before merging the Git commit that points to them. Otherwise, another teammate or CI job may receive a pointer without being able to download its content.
A useful branch setup is one pipeline change per branch. This keeps changes to dvc.lock easier to review. Reviewers should inspect the commands, dependencies, parameters, and outputs in dvc.yaml, not only the Python code.
Configure credentials safely
The remote URL can be committed in .dvc/config. Credentials should not be committed. Store them in a local configuration file, a credential helper, or the CI provider's secret store.
For example, an S3-backed remote can use environment variables supplied by the developer's AWS configuration or by CI:
git checkout -b improve-features
git pull --ff-only origin main
dvc pull
dvc repro
dvc status
dvc push
git add dvc.yaml dvc.lock params.yaml metrics.json
git commit -m "Tune feature preparation"
git push --set-upstream origin improve-featuresgit pull --ff-only refuses to create an unexpected merge commit. If another teammate changed the same pipeline files, resolve the Git conflict deliberately. After resolving a conflict in dvc.yaml or dvc.lock, run dvc repro and inspect the resulting lock file before committing.
A DVC remote usually stores objects by content hash. Two commits that refer to the same object can reuse that object, which reduces duplicate storage. The remote must still be protected with access controls and backups.
Validate changes in CI
CI should use a clean checkout. It must install the DVC adapter required by the remote, obtain credentials from secrets, pull the referenced data, and run the pipeline or a targeted validation.
A minimal GitHub Actions job might look like this:
name: Validate DVC pipeline
on:
pull_request:
jobs:
reproduce:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install "dvc[s3]"
- name: Configure cloud credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-1
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Fetch data and reproduce pipeline
run: |
dvc pull
dvc repro
dvc statusCI needs permission to read the DVC remote, but it usually should not have permission to delete objects or upload arbitrary data. A separate trusted job can publish approved outputs with narrower conditions.
Common team failures
- A committed pointer has no matching remote object because someone forgot
dvc push. - CI cannot download data because its DVC plugin or credentials are missing.
- A merge resolves
dvc.locktextually but leaves a pipeline that no longer matches its dependencies. - Two jobs write to the same mutable remote location, causing non-reproducible results.
- Secrets are placed in
.dvc/configor command-line logs.
Use immutable paths or versioned output locations for published datasets and models. Treat a successful dvc repro and a successful dvc push as separate checks.
Exercise
What must happen before merging a Git commit that references a newly generated DVC output?
Show answer
The output must be pushed to the shared DVC remote, and CI or a teammate must be able to download it with the committed pointer files.