Search code examples
gitdvcsdvc

DVC Experiment management workflow


I'm struggling with the DVC experiment management. Suppose the following scenario:

I have params.yaml file:

recommendations:
  k: 66
  q: 5

I run the experiment with dvc exp run -n exp_66, and then I do dvc exp push origin exp_66. After this, I modify params.yaml file:

recommendations:
  k: 99
  q: 5

and then run another experiment dvc exp run -n exp_99, after which I commit with dvc exp push origin exp_99.

Now, when I pull the corresponding branch with Git, I try to pull exp_66 from dvc by running dvc exp pull origin exp_66. This does the pull (no error messages), but the content of the params.yaml file is with k: 99 (and I would expect k: 66). What am I doing wrong? Does git push have to be executed after dvc push? Apart from that, I also found dvc exp apply exp_66, but I'm not sure what it does (it is suggested that after apply one should execute git add ., then git commit?

I would really appreciate if you could write down the workflow with committing different experiments, pushing, pulling, applying, etc.


Solution

  • You did everything alright. In the end, after pulling, you can see that when using dvc exp show your experiments will be there. To restore the experiment available from your experiment list into your workspace, you simply need to run dvc exp apply exp_66. DVC will make sure that the changes corresponding to this experiment will be checked out.

    Your workflow seems correct so far. One addition: once you make sure one of the experiments is what you want to "keep" in git history, you can use dvc exp branch {exp_id} {branch_name} to create a separate branch for this experiment. Then you can use git commands to save the changes.