Skip to main content

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.
This command modifies your workspace. Any uncommitted changes will be overwritten. Commit or stash your current work before applying an experiment.

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 -n during dvc 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

Output:
After applying, your workspace now matches the state of the experiment including code, parameters, and outputs.

Apply and commit

Output:
Applying an experiment doesn’t automatically create a Git commit. Review the changes first, then commit when ready.

Apply with existing changes

Output:
DVC automatically creates a stash at refs/exps/apply/stash before applying. You can revert using:

Compare before applying

Output:

Apply and create a branch

This workflow is useful for code review: apply the experiment to a branch, then create a pull request.

What Gets Applied

When you apply an experiment, DVC updates:

1. Parameters

  • params.yaml and other parameter files are updated with experiment values
  • Custom parameter files specified in dvc.yaml are 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.lock is 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:
Resolve manually:

Missing Experiment

If the experiment doesn’t exist:
Output:
List available experiments:
  • dvc exp show - View available experiments
  • dvc exp diff - Compare experiments before applying
  • dvc exp branch - Promote experiment to a Git branch
  • dvc exp run - Create new experiments
  • dvc checkout - Checkout DVC-tracked files after applying