-
Notifications
You must be signed in to change notification settings - Fork 1.2k
dvc check-ignore
command
#4282
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
dvc check-ignore
command
#4282
Conversation
abspath Co-authored-by: Ruslan Kuprieiev <[email protected]>
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.
Looks great!
Some notes, one change request (_get_normalize_path
)
"file,ret,output", | ||
[ | ||
("file", 0, "{}:1:f*\tfile\n".format(DvcIgnore.DVCIGNORE_FILE)), | ||
("foo", 0, "{}:2:!foo\tfoo\n".format(DvcIgnore.DVCIGNORE_FILE)), |
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.
shouldn't we return 1 in this use case?
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.
Hmm, just tested it with git
and it seems that even if you exclude file, 0 is returned.
According to doc 0 should be returned when given path is ignored. So I would say that this is a bug in git
. @karajan1001 @efiop 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.
@pared
This is what I would like to discuss.
Yes In Git, 0 should be returned when a given path is ignored. But 0 returns on any pattern match the file either included or excluded, 1 returns when none of the pattern match. (It might be a bug or a feature not clearly documented. I sent an email to Git last time but no reply)
But I felt illogical on this results. 0 for ignored and 1 for included or not matched might be more reasonable.
As a result. I left matches
in
CheckIgnoreResult = namedtuple(
"CheckIgnoreResult", ["file", "matches", "patterns"]
)
which could be used for marking whether it is ignored or not.
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.
@karajan1001
To me, it seems that either docs is wrong (because it says that 0 is returned if file is ignored) or implementation (which returns 0 upon any matching spec). I'll try to reach git-devel IRC, maybe we can get an answer faster.
For now, we can leave it as is.
# skip system pattern | ||
if not pattern.file_info: | ||
continue |
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.
Won't that result in no matches for .git
and return 1 when we do check-ignore .git
?
I guess in one way this is right behavior, since its not specified in any file, but, its also against tree.walk
behavior which will ignore .git
.
But I guess main point of check-ignore
is to debug .dvcignore
s, so its fine.
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.
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.
If that's not too much trouble, sure. But if its, feel free to keep it that way.
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.
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.
@karajan1001 you mean the proper git return code?
To avoid unnecessary change requests, let's leave it as is.
@pared
with
runs faster when |
@karajan1001 |
Thank you, if-condition is more readable and try-catch separates exception handling and function logic (All Exceptions been handled at one place and one level). The best practice might be sharing the same standard all over the project for all contributors. Because it makes us more ease to understand each other's code. |
Co-authored-by: Jorge Orpinel <[email protected]>
Co-authored-by: Jorge Orpinel <[email protected]>
p.s. being able to review docs and core at the same time has some great benefits, especially when the draft doc is so thorough and with comprehensive examples so kudos and thanks again @karajan1001 ! |
@karajan1001 Sorry for the delay :)
There is no strict policy. As you've noticed we mix and match these at different places in the code. For example, stuff like As always, thank you for contributing amazing stuff! π |
Part of the issue is a bug from iterative#3806 Kudos to @karajan1001 for finding this bug while working on iterative#4282
Part of the issue is a bug from #3806 Kudos to @karajan1001 for finding this bug while working on #4282
This reverts commit 27eec49.
1. Argument `targets`'s description. 2. Error handling of `_get_normalize_path`
@pared @efiop Reverted to the previous version, but several problems still remained. Maybe it's better to create independent issues for each?
CI had failed for
|
dvc/main.py
Outdated
@@ -84,7 +84,7 @@ def main(argv=None): # noqa: C901 | |||
ret = 255 | |||
|
|||
try: | |||
if ret != 0: | |||
if ret != 0 and ret != 1: |
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 this is no longer needed after the rebase
if ret != 0 and ret != 1: | |
if ret != 0: |
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.
@efiop
Still got this warning after I deleted ret != 1
Return numbers are used for those who want to do some ignore-check in a script. We might solve it in two ways:
- Return number only available in a
--quiet
mode, without-q
they are always 0 - Alert not show for some non-zero numbers.
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.
@karajan1001, or just do something like this for now:
if ret == 1 and args and args.cmd == "check-ignore":
pass
Not ideal, but should work for now.
Co-authored-by: Ruslan Kuprieiev <[email protected]>
1. Add a new test for the out side repo cases 2. check ignore now only check one file not file lists
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.
Cool stuff! Thank you @karajan1001 ! π
"targets", | ||
nargs="+", | ||
help="Exact or wildcard paths of files or directories to check " | ||
"ignore patterns.", |
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.
That sentence is a bit confusing. How about "File or directory paths, or ignore patterns to check"
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.
@jorgeorpinel
I think the targets we checked here are wildcard patterns not ignore patterns. It's a pattern used in file searches so the full name need not be typed provided by the file system. For example, we have
aa
ab
bb
in our current path.
The command dvc check-ignore a*
equals to dvc check-ignore aa ab
. Our program received a list of files instead of a single pattern a*
.
Only my personal opinion, not good at English, maybe ignore patterns
can represent the same meaning?
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.
the targets we checked here are wildcard patterns not ignore patterns
Good to know, thanks! Confusing probably... but makes sense. So those depend on the OS? I.e. POSIX shells have accept different wildcards than, say, Windows PowerShell.
And yeah no worries, it's getting too deep. I'll take care of rewriting it as needed in iterative/dvc.org/pull/1629 and submit a matching PR to the core repo.
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.
Went for "File or directory paths to check (wildcards supported)" in iterative/dvc.org/pull/1629.
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.
Just "File or directory paths to check" now... See #1673
|
||
|
||
def add_parser(subparsers, parent_parser): | ||
ADD_HELP = "Debug DVC ignore/exclude files" |
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.
How about something like "Check whether files or directories are excluded due to .dvcignore
." ?
Per https://github.com/iterative/dvc.org/pull/1629/files
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.
@johntharian
No problem.
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.
Wrong handle π
@jorgeorpinel |
No problem, I'll submit a PR when I get a chance. |
* check_ignore: update help output per #4282 (review) and #4282 (review) * check-ignore: more output string updates per #4323 et al. * check-ignore: min text update to match iterative/dvc.org/pull/1673 Co-authored-by: Ruslan Kuprieiev <[email protected]>
update some tests first
fix #3736
β I have followed the Contributing to DVC checklist.
π If this PR requires documentation updates, I have created a separate PR (or issue, at least) in dvc.org and linked it here.
Docs for new command
dvc check-ignore
Β dvc.org#1629Thank you for the contribution - we'll try to review it as soon as possible. π