Description
Apply the changes from a specific experiment to your current workspace. This command updates your working directory with the code, parameters, and data from a completed experiment, allowing you to continue working from that state or promote it to a regular Git commit.Usage
Arguments
string
required
The experiment name to apply to your workspace.Can be:
- Auto-generated experiment name (e.g.,
exp-a1b2c) - Custom experiment name (specified with
-nduringdvc exp run)
Options
boolean
default:"false"
Fail if this command would overwrite conflicting changes in the workspace.
The
--no-force option is deprecated and will be removed in a future DVC release.Examples
Apply a successful experiment
After applying, your workspace now matches the state of the experiment including code, parameters, and outputs.
Apply and commit
Apply with existing changes
Compare before applying
Apply and create a branch
What Gets Applied
When you apply an experiment, DVC updates:1. Parameters
params.yamland other parameter files are updated with experiment values- Custom parameter files specified in
dvc.yamlare also updated
2. Code Changes
- Any code modifications made during the experiment are applied
- This includes changes to training scripts, preprocessing code, etc.
3. DVC Files
dvc.lockis updated with the experiment’s pipeline state- Cached outputs from the experiment become accessible
4. Metrics
- Metric files are updated to reflect experiment results
Large data files tracked by DVC are not copied to your workspace. Instead, DVC updates pointers to the cached data. Use
dvc checkout if you need to materialize the data files.Common Workflows
Experiment Selection Workflow
Safe Experimentation Workflow
Production Promotion Workflow
Reverting Applied Changes
If you need to undo an applied experiment:DVC creates a backup stash at
refs/exps/apply/stash before each apply operation, allowing you to recover your previous state.Troubleshooting
Merge Conflicts
If applying an experiment causes conflicts:Missing Experiment
If the experiment doesn’t exist:Related Commands
dvc exp show- View available experimentsdvc exp diff- Compare experiments before applyingdvc exp branch- Promote experiment to a Git branchdvc exp run- Create new experimentsdvc checkout- Checkout DVC-tracked files after applying