-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Special dir warning #3436 #4229
Merged
Merged
Changes from 3 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
94668a8
add special folder warning
aerubanov 8686f0d
add special folder warning
aerubanov e0b26fc
merge
aerubanov 7dde434
remove special folder warning, start working on default dvcignore
aerubanov 0fa1a20
Merge branch 'master' into special_dir_warning
aerubanov a3ee328
add default .dvcignote and templates
aerubanov f98d742
remove dvcignore templates
aerubanov e8994dd
change text and add tests
aerubanov 8da4d50
Merge branch 'master' into special_dir_warning
aerubanov abfa2dc
refactor
efiop 50c0c84
dvcignore: ignore comments
efiop 824fbeb
adjust tests
efiop File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,6 +148,37 @@ def __eq__(self, other): | |
return self.basenames == other.basenames | ||
|
||
|
||
class DvcWarningDirs: | ||
special_dirs = { | ||
".petest_cache", | ||
".mypy_cache", | ||
"node_modules", | ||
".venv", | ||
"venv", | ||
"env", | ||
"__pycache__", | ||
"dist", | ||
"eggs", | ||
"wheels", | ||
"htmlcov", | ||
"docs", | ||
".ipynb_checkpoints", | ||
".vscode", | ||
".github", | ||
} | ||
|
||
def __call__(self, root, dirs, files): | ||
for d in dirs: | ||
if d in self.special_dirs: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we could do something like |
||
print( | ||
f"Warning: {d} found in dvc, traversing may be slow." | ||
f" You can add it in .dvcignore. See more " | ||
f"https://dvc.org/doc/user-guide/dvcignore" | ||
) | ||
|
||
return dirs, files | ||
|
||
|
||
class DvcIgnoreRepo(DvcIgnore): | ||
def __call__(self, root, dirs, files): | ||
def is_dvc_repo(directory): | ||
|
@@ -181,6 +212,7 @@ def __init__(self, tree, root_dir): | |
self.ignores = { | ||
DvcIgnoreDirs([".git", ".hg", ".dvc"]), | ||
DvcIgnoreRepo(), | ||
DvcWarningDirs(), | ||
} | ||
ignore_pattern_trie = DvcIgnorePatternsTrie() | ||
for root, dirs, _ in self.tree.walk(self.root_dir): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, makes me wonder if we should really just ignore them by default (like we do with .git and .hg), and if some user really needs these, he could
!something
in dvcignore to include it.Or, we might consider generating a default .dvcignore (kinda like github generates .gitignore when you create a project) to make it extra explicit. Though this is simple on
init
, but managing this stuff in existing projects is not too simple 🙁I'm just worried about these warnings getting too annoying. Plus, unless I'm missing something, ignore execution order is not deterministic (that's actually is a bigger problem for us in general), so you never know if this filter will be executed before or after .dvcignores in which user has ignored a special dir explicitly. 🙁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more thing that this makes me think about is having some kind of safe guard, that would, for example, record the amount of time it took to walk through the directory and warn if it didn't find anything but it took, say, more than 5 sec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This issue was opened after this conversation #3257. It was decided that it is better to warn the user if a special directory is found than to ignore it by default. But annoyance from warnings can be a problem. Maybe we should make it possible to disable this warning? From the other hand, the default .dvcignore also good idea because the ignore will be explicite to the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What makes idea of default
.dvcignore
compelling, is the fact that is not only explicit, but also editable by user.If we decide to go with warnings, they definitely need turn off mechanism, just like we did with
slow_link_guard
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I soppouse that the default
.dvcignore
, is better option. It`s more explicite and easy to configure. Also the list of special dirs always will be incomplite, we can not add all posiible variants here. And default.dvcignore
provide additional example for users how to deal with such cases.@efiop, @pared, if you are agree with me, then I will change the code. Should I close this PR and open a new one later, or commit right here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I love the idea of an explicit
.dvcignore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder whether it should be default. Maybe we should add some option to init, or dedicate special command for that? It seems to me that
.dvcignore
was supposed to let user decide what is part of his project. If we always create default.dvcignore
on init, we make it our choice. @efiop @aerubanov, what do you think?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that default
.dvcignore
should consist comment with link to the dvcignore documentation. And we should add option for init to filling.dvcignore
with some content. Not all list of special folder, rather based on type of project specified by user. Something like github gitignore template https://github.com/github/gitignore, but with fewer options ofcorse.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aerubanov I think you are right on this one.