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

Two new modes --all and --stdin for check-ignore #4323

Merged
merged 13 commits into from
Aug 6, 2020

Conversation

karajan1001
Copy link
Contributor

Fix #4321

Introduce new arguments --all for dvc check-ignore
Add tests for dvc check-ignore --all

Thank you for the contribution - we'll try to review it as soon as possible. πŸ™

Fix iterative#4321

Introduce new arguments --all for dvc check-ignore
Add tests for dvc check-ignore --all
@efiop efiop requested a review from pared August 3, 2020 11:52
@efiop efiop changed the title Two new mode -all and --stdin for check-ignore Two new modes --all and --stdin for check-ignore Aug 4, 2020
Copy link
Contributor

@pared pared left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, one change request.

dvc/command/check_ignore.py Outdated Show resolved Hide resolved
1. `--stdin` and targets can and only can have one
2. more tests
@karajan1001
Copy link
Contributor Author

LGTM, one change request.
@pared
Thank you, I'm so careless to write such a bug.

And I had a problem. I tried to add a pytest to --stdin mode but failed.

I used monkeypatch to mock user input but was blocked by

if not sys.stdout.isatty():

Are there any methods to pass this line?

@pared
Copy link
Contributor

pared commented Aug 4, 2020

@karajan1001
I guess most straightforward would be to mock isatty too, though I will see if there is something else to be done here.

@codecov
Copy link

codecov bot commented Aug 4, 2020

Codecov Report

Merging #4323 into master will decrease coverage by 0.04%.
The diff coverage is 71.05%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4323      +/-   ##
==========================================
- Coverage   91.24%   91.19%   -0.05%     
==========================================
  Files         177      177              
  Lines       12182    12209      +27     
==========================================
+ Hits        11115    11134      +19     
- Misses       1067     1075       +8     
Impacted Files Coverage Ξ”
dvc/command/experiments.py 45.12% <0.00%> (-0.34%) ⬇️
dvc/repo/experiments/__init__.py 85.71% <72.22%> (-1.79%) ⬇️
dvc/updater.py 86.58% <100.00%> (ΓΈ)

Continue to review full report at Codecov.

Legend - Click here to learn more
Ξ” = absolute <relative> (impact), ΓΈ = not affected, ? = missing data
Powered by Codecov. Last update 11d906e...a504fa3. Read the comment docs.

1. Add a new tests with mock stdin for interactive mode
2. Solve the problem of `assert "" in caplog.text` in tests always `True`.
@karajan1001
Copy link
Contributor Author

@karajan1001
I guess most straightforward would be to mock isatty too, though I will see if there is something else to be done here.

@pared
Oh thank you very much, it works. But I don't know if there are some risks to influence other tests.

@pared
Copy link
Contributor

pared commented Aug 5, 2020

@karajan1001

But I don't know if there are some risks to influence other tests.

When you are using a mocker inside a test, patches and mocks are applied only to this test. So, if you are worried, whether it's possible to "leak" the mock to other tests - no, it should not happen.

I will see if there is something else to be done here

I think it's fine to use this patch. isatty tests whether we are working from terminal, so it is a situation we are trying to simulate.

@jorgeorpinel
Copy link
Contributor

Hi!

Maybe you can address #4282 (review) and #4282 (review) here @karajan1001 ? Thanks!

@efiop
Copy link
Contributor

efiop commented Aug 6, 2020

Maybe you can address #4282 (review) and #4282 (review) here @karajan1001 ? Thanks!

@jorgeorpinel Let's not do that. Let's not expand the scope of this PR, those changes are completely unrelated.

@karajan1001
Copy link
Contributor Author

Maybe you can address #4282 (review) and #4282 (review) here @karajan1001 ? Thanks!

@jorgeorpinel Let's not do that. Let's not expand the scope of this PR, those changes are completely unrelated.

I had considered doing so, but give up. BTW, doc of this PR needs to be reviewed as well.

dvc/prompt.py Outdated Show resolved Hide resolved
1. remove path_input and make _ask to a public method instead
dvc/command/check_ignore.py Outdated Show resolved Hide resolved
dvc/command/check_ignore.py Outdated Show resolved Hide resolved
dvc/command/check_ignore.py Outdated Show resolved Hide resolved
dvc/command/check_ignore.py Outdated Show resolved Hide resolved
dvc/command/check_ignore.py Outdated Show resolved Hide resolved
dvc/command/check_ignore.py Outdated Show resolved Hide resolved
dvc/command/check_ignore.py Outdated Show resolved Hide resolved
dvc/command/check_ignore.py Outdated Show resolved Hide resolved
@efiop efiop merged commit e2a5741 into iterative:master Aug 6, 2020
@efiop
Copy link
Contributor

efiop commented Aug 6, 2020

Thank you @karajan1001 ! πŸ™

There are some tiny inconsistencies with stuff like messages, but we'll adjust them along the way. It is great to have such a powerful tool in our toolbox!

@jorgeorpinel
Copy link
Contributor

jorgeorpinel commented Aug 7, 2020

BTW, doc of this PR needs to be reviewed as well.

@karajan1001 is there a docs PR for this already? We haven't even merged the previous one πŸ˜… (see iterative/dvc.org#1629 (comment))

@karajan1001
Copy link
Contributor Author

@jorgeorpinel

Not already, I'm waiting for this one. And it would be created soon.

Comment on lines +44 to +45
"Empty string is not a valid pathspec. Please use . "
"instead if you meant to match all paths."
Copy link
Contributor

@jorgeorpinel jorgeorpinel Aug 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is a pathspec?

Can users actually send an empty string (e.g. '')? Or does this happen when you don't send any args?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jorgeorpinel

  1. pathspec means the target to be checked
  2. It is in an interactive mode where users can type string as the target, and this happened when users type send an empty string.

Copy link
Contributor

@jorgeorpinel jorgeorpinel Aug 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is in an interactive mode

So maybe don't say anything and just go to the next > ? Seems intuitive enough that way. I just tried it and noticed it crashes after this error msg (i.e. it stops the interactive mode).

UPDATE: On Windows at least, there's no > chars in interactive mode, see iterative/dvc.org#1675 (review)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p.s. when I send an empty string as target i.e. dvc check-ignore '' it just checks it (never matches even if * is a pattern in .dvcignore) and this error isn't presented. Seems slightly inconsistent. I vote to just remove it altogether πŸ™‚

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracted to #4361

Comment on lines +74 to +75
if self.args.quiet and self.args.details:
raise DvcException("cannot use both `--details` and `--quiet`")
Copy link
Contributor

@jorgeorpinel jorgeorpinel Aug 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe --quiet should just win here?

Copy link
Contributor Author

@karajan1001 karajan1001 Aug 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe --quiet should just win here?

Yes, it used to be --verbose and --quiet. They might cause some problems, and had been fixed in #4304.
And for --details and --quiet we can just let --quiet win.

Copy link
Contributor

@jorgeorpinel jorgeorpinel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some questions @karajan1001 ☝️

We can discuss my other suggestions in iterative/dvc.org/pull/1675 and I'll apply them (probably in #4358).

jorgeorpinel added a commit to karajan1001/dvc.org that referenced this pull request Aug 7, 2020
jorgeorpinel added a commit to karajan1001/dvc.org that referenced this pull request Aug 7, 2020
jorgeorpinel added a commit to iterative/dvc.org that referenced this pull request Aug 7, 2020
jorgeorpinel added a commit that referenced this pull request Aug 7, 2020
shcheklein pushed a commit to iterative/dvc.org that referenced this pull request Aug 8, 2020
* cmd: remove unnecessary commas in get and import

* cmd: fix typo in add

* cmd: remote copy edits
per #1617 (comment)

* guide: .dvcignore copy edit

* cmd: init copy edits

* clarify about dirs in import -o

* cmd: review get -o desc

* dvcignore: updates to guide and check-ignore ref.
per #1629 (review)
et al.

* cmd: update check-ignore -n
per iterative/dvc#4323 (comment)

* cmd: fix get.import -o descriptions
per #1673 (review)
and #1673 (review)

* cmd: copy edits to remote add/modify
efiop added a commit that referenced this pull request Aug 11, 2020
* 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]>
@karajan1001 karajan1001 deleted the fix_4321 branch April 7, 2021 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Interactive mode and all patterns mode for dvc check-ignore command
4 participants