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

checkout: don't ask for removal confirmation if we have that file in the cache #1366

Closed
efiop opened this issue Nov 26, 2018 · 2 comments
Closed
Labels
enhancement Enhances DVC
Milestone

Comments

@efiop
Copy link
Contributor

efiop commented Nov 26, 2018

#!/bin/bash

set -e
set -x

rm -rf myrepo
mkdir myrepo
cd myrepo
git init
dvc init
git commit -m"init"

git checkout -b foo
echo foo > file

dvc add file
git add file.dvc .gitignore
git commit -m foo

git checkout master
git checkout -b bar
dvc checkout

echo bar > file
dvc add file
git add file.dvc .gitignore
git commit -m bar

git checkout foo
dvc checkout

shouldn't ask for confirmation when deleting file, since it has that version in the cache already.

@efiop efiop added the enhancement Enhances DVC label Nov 26, 2018
@efiop efiop added this to the Queue milestone Nov 26, 2018
@ghost ghost self-assigned this Nov 26, 2018
@ghost
Copy link

ghost commented Nov 26, 2018

We would need to recompute the checksum for every file we check, as we don't know if it has changed or not.

#!/bin/bash

set -e
set -x

rm -rf myrepo
mkdir myrepo
cd myrepo
git init
dvc init
git commit -m"init"

git checkout -b foo
echo foo > file

dvc add file
git add file.dvc .gitignore
git commit -m foo

git checkout master
git checkout -b bar
dvc checkout

echo bar > file
dvc add file
git add file.dvc .gitignore
git commit -m bar

git checkout foo
+ echo other_content > file
dvc checkout

What we are trying to achieve is preventing the user from deleting files that are "work in progress" (a dirty working directory) when checking out.

I'll submit a patch for it, but I can't imagine how expensive would be to recalculate MD5s in order to know which files are safe to delete without prompting.

What do you think, @efiop ?

@efiop
Copy link
Contributor Author

efiop commented Nov 26, 2018

@MrOutis If that file is already in cache and was linked to the workspace by dvc, then the checksum for it is already cached and costs nothing to retrieve. Otherwise we do re-compute the checksum, since we need to ensure that checksum is the one or not the one we need. We actually do that already, see https://github.com/iterative/dvc/blob/master/dvc/state.py#L87 . Or, another possibility, is to simply check if that file is in our link_state table(https://github.com/iterative/dvc/blob/master/dvc/state.py#L346), so we quickly know that it was indeed created by us and can be removed safely.

efiop pushed a commit that referenced this issue Nov 26, 2018
* local: Don't prompt at removal if file is already cached

Fix #1366

* [fix] Do `remove` at `save_remove`

* Use `state.update` to compute checksum instead of `save_info`

* PEP8 compilant
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhances DVC
Projects
None yet
Development

No branches or pull requests

1 participant