Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exp apply: unable to apply an experiment when there are unsaved changes in the workspace #9991

Closed
mattseddon opened this issue Oct 3, 2023 · 0 comments · Fixed by #9992 or #10051
Closed
Assignees
Labels
A: experiments Related to dvc exp

Comments

@mattseddon
Copy link
Member

mattseddon commented Oct 3, 2023

Bug Report

Description

I am unable to apply an experiment when there are "unsaved changed" in the workspace.

Reproduce

Run an experiment which creates "unsaved changes" in the workspace. Try to apply a different experiment. No combination of flags will enable you to do this before running dvc checkout exp --force.

~/projects/vscode-dvc-demo main *1 !4 ❯ dvc exp apply 0419d97                                                                                                    
Building workspace index                                                                                                                                              |43.0 [00:00, 4.84kentry/s]
Comparing indexes                                                                                                                                                     |42.0 [00:00, 5.68kentry/s]
ERROR: Can't remove the following unsaved files without confirmation. Use `--force` to force.
~/projects/vscode-dvc-demo/hist.csv
~/projects/vscode-dvc-demo main *1 ❯ dvc exp apply 0419d97 --force
ERROR: unrecognized arguments: --force
usage: dvc experiments apply [-h] [-q | -v] [--no-force] experiment

Apply the changes from an experiment to your workspace.
Documentation: <https://man.dvc.org/exp/apply>

positional arguments:
  experiment     Experiment to be applied.

options:
  -h, --help     show this help message and exit
  -q, --quiet    Be quiet.
  -v, --verbose  Be verbose.
  --no-force     Fail if this command would overwrite conflicting changes.
~/projects/vscode-dvc-demo main *1 ❯ dvc exp apply 0419d97 --no-force
The --no-force option is deprecated and will be removed in a future DVC release. To revert the result of 'exp apply', run:

        git reset --hard
        git stash apply refs/exps/apply/stash

Building workspace index                                                                                                                                              |43.0 [00:00, 5.44kentry/s]
Comparing indexes                                                                                                                                                     |42.0 [00:00, 5.91kentry/s]
ERROR: Can't remove the following unsaved files without confirmation. Use `--force` to force.
~projects/vscode-dvc-demo/hist.csv
~/projects/vscode-dvc-demo main *1 ❯ dvc exp apply 0419d97 --no-force false
ERROR: unrecognized arguments: false
usage: dvc experiments apply [-h] [-q | -v] [--no-force] experiment

Apply the changes from an experiment to your workspace.
Documentation: <https://man.dvc.org/exp/apply>

positional arguments:
  experiment     Experiment to be applied.

options:
  -h, --help     show this help message and exit
  -q, --quiet    Be quiet.
  -v, --verbose  Be verbose.
  --no-force     Fail if this command would overwrite conflicting changes.

Expected

--force should work as expected.

Environment information

Output of dvc doctor:

$ dvc doctor
DVC version: 3.23.0 (pip)
-------------------------
Platform: Python 3.10.10 on macOS-14.0-arm64-arm-64bit
Subprojects:
        dvc_data = 2.16.4
        dvc_objects = 1.0.1
        dvc_render = 0.6.1.dev22+g1c4428a
        dvc_task = 0.3.0
        scmrepo = 1.3.1
Supports:
        http (aiohttp = 3.8.4, aiohttp-retry = 2.8.3),
        https (aiohttp = 3.8.4, aiohttp-retry = 2.8.3),
        s3 (s3fs = 2023.9.1, boto3 = 1.28.17)
Config:
        Global: /Users/mattseddon/Library/Application Support/dvc
        System: /Library/Application Support/dvc
Cache types: reflink, hardlink, symlink
Cache directory: apfs on /dev/disk3s1s1
Caches: local
Remotes: s3
Workspace directory: apfs on /dev/disk3s1s1
Repo: dvc, git
Repo.site_cache_dir: /Library/Caches/dvc/repo/42de5bfa7eb2fd81cac7807679eceb92

Additional Information (if any):

Seems like this is happening because --force is not being passed to dvc_checkout further down the chain. I raised a PR (#9992) to close this issue please LMK if that was not the correct approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: experiments Related to dvc exp
Projects
None yet
2 participants