dvc icon indicating copy to clipboard operation
dvc copied to clipboard

`dvc queue run <hash>` to run a specific experiment

Open PythonFZ opened this issue 3 years ago • 18 comments

I'm using the dvc experiment feature together with the queue to plan multiple experiments I want to run. I wanted to run an already queued experiment to check its outputs without submitting all jobs.

My Idea would be something like dvc queue run <hash> which will run the given experiment in .dvc/tmp/ and upon success remove it from the queue.

PythonFZ avatar Aug 10 '22 14:08 PythonFZ

Keeping this feature request open, but in case you want a workaround for this in the meantime, you can do:

$ dvc exp apply <queue_id>
$ dvc exp run --temp

dberenbaum avatar Aug 11 '22 12:08 dberenbaum

Thanks, I had to add dvc queue remove to clean the queue from the old experiment which would just be a copy. But this was more or less exactly what I was looking for.

dvc exp apply $queue_id
dvc exp run --temp
dvc queue remove $queue_id

PythonFZ avatar Aug 11 '22 12:08 PythonFZ

Maybe dvc queue pop <hash> would make sense as an alias for that?

dberenbaum avatar Aug 11 '22 12:08 dberenbaum

It probably can't be dvc queue run <hash> because the id changes so I like the dvc queue pop <hash> idea. How would this affect the workspace? If you use apply + run --temp it will change the workspace, so maybe use stash the workflow before the apply and then apply the stash afterwards?

PythonFZ avatar Aug 11 '22 13:08 PythonFZ

In addition to dvc queue pop <id> one could also have just dvc queue pop to start the next experiment in line. In this way one can run multiple experiments in temporary directories from the same repository. This could be especially useful on shared file systems to run experiment from different machines.

PythonFZ avatar Mar 23 '23 16:03 PythonFZ

I found a solution for myself by writing https://github.com/zincware/dask4dvc and adding this feature via dask4dvc run <id> which will reproduce the specific experiment.

PythonFZ avatar Apr 22 '23 15:04 PythonFZ

Nice @PythonFZ! Any interest in submitting a PR to do it in DVC?

dberenbaum avatar Apr 24 '23 12:04 dberenbaum

Thanks, I had to add dvc queue remove to clean the queue from the old experiment which would just be a copy. But this was more or less exactly what I was looking for.

dvc exp apply $queue_id
dvc exp run --temp
dvc queue remove $queue_id

does this work in the case of multiple workers assuming the workers aren't trying to do dvc exp apply at the same time? once the call to dvc exp run --temp is called, can the workspace be safely changed by another worker with dvc exp apply?

gregstarr avatar Jun 08 '23 22:06 gregstarr

@gregstarr Could you clarify your concern or explain further?

dberenbaum avatar Jun 15 '23 18:06 dberenbaum

I'll use tmux for an example:

Assume I already have a list of experiments queued. I open a window, cd to my repo and begin the experiment using dvc exp apply $queue_id, dvc exp run --temp. Can I then open another tmux window and do the same steps again for a different experiment?

gregstarr avatar Jun 15 '23 20:06 gregstarr

Yes, as long as you are okay that each dvc exp apply call will change the state of your workspace. dvc exp run --temp will create a new isolated workspace for each one and run them in parallel.

dberenbaum avatar Jun 16 '23 01:06 dberenbaum

Okay, is there a command which would restore the workspace to how it was before dvc exp apply was called?

gregstarr avatar Jun 16 '23 02:06 gregstarr

You can git stash --include-untracked before you dvc exp applyand see if git stash pop does work.

@dberenbaum Unfortunately, I won't be able to add my dask4dvc implementation because it doesn't work with celery.

PythonFZ avatar Jun 16 '23 03:06 PythonFZ

how does dvc deal with this issue? when I queue up experiments with dvc exp run --queue -S param1=val1 ... the workspace is left unchanged afterwards right?

gregstarr avatar Jun 16 '23 10:06 gregstarr

@gregstarr PTAL at https://dvc.org/doc/command-reference/exp/apply#expand-for-details-on-reverting-object-object and see if that helps

dberenbaum avatar Jun 16 '23 14:06 dberenbaum

yes that does help, thank you!

just to make sure I understand:

  • git stash would save any changes I made to the experiment
  • then git stash apply refs/exps/apply/stash restores the workspace to how it was prior to the dvc exp apply

is this correct? I'm assuming dvc exp apply saves a stash in "refs/exps/apply/stash" prior to applying the experiment stash? then the second command retrieves it?

gregstarr avatar Jun 16 '23 15:06 gregstarr

Correct. @pmrowla please correct if you see anything wrong above.

dberenbaum avatar Jun 16 '23 15:06 dberenbaum

thanks 👍

gregstarr avatar Jun 16 '23 15:06 gregstarr