Skip to content

diff: add support for --targets#4938

Merged
efiop merged 9 commits into
treeverse:masterfrom
sandeepmistry:issue-3388-diff-target
Dec 15, 2020
Merged

diff: add support for --targets#4938
efiop merged 9 commits into
treeverse:masterfrom
sandeepmistry:issue-3388-diff-target

Conversation

@sandeepmistry
Copy link
Copy Markdown
Contributor

@sandeepmistry sandeepmistry commented Nov 23, 2020

Thank you for the contribution - we'll try to review it as soon as possible. 🙏


Will close #3388.

The filter code needs to be improved (something smarter than starts with) and I think an error needs to be outputted if the target parameter is not found in the list of tracked files or folders. The documentation will also need to be updated accordingly once this is merged.

For now I've started with the original behaviour the issue started with (optional --target arg). Let me know if the behaviour from comment #3388 (comment) would be preferred (dvc diff [-h] [-q | -v] [-t TARGET] [--show-json] [--show-hash] [--show-md] [--hide-missing] [a_rev] [b_rev] [targets [targets]]).

Comment thread dvc/command/diff.py Outdated
@efiop efiop requested a review from pmrowla November 23, 2020 03:19
Comment thread dvc/repo/diff.py Outdated
Comment thread dvc/repo/diff.py Outdated
@sandeepmistry sandeepmistry changed the title [WIP] add target support (back) to dvc diff [WIP] add targets support to dvc diff Nov 29, 2020
Comment thread dvc/repo/diff.py Outdated
@sandeepmistry
Copy link
Copy Markdown
Contributor Author

@efiop please take a look at the latest changes when you get a chance.

If things look good I will proceed to added tests and updating the documentation.

Comment thread dvc/path_info.py Outdated
Comment thread dvc/path_info.py Outdated
Comment thread dvc/repo/diff.py Outdated
Comment thread dvc/repo/diff.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

isin() will not cover every case here, I think we need to use path_info.overlaps(...) instead.

Let's say, output is a tracked directory dir/, which contains a file foo. output.path_info here will contain the path to the tracked dir: dir/.

If our target is dir/foo, output.path_info.isin_or_eq(target) will be False. In this case the output dir/ itself should not be yielded (which you have correctly accounted for already), but the file dir/foo within output does need to be yielded (meaning we still have to call _dir_output_paths(...)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think this was working before because yield_output was set to no_targets or output.path_info.isin_or_eq(targets).

I've done another pass to try to make this clearer let me know. Also, let me know if there is an additional scenario for this that needs to be covered in the unit test I added.

Comment thread dvc/repo/diff.py Outdated
Copy link
Copy Markdown
Contributor

@pmrowla pmrowla left a comment

Choose a reason for hiding this comment

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

@sandeepmistry Nice progress on this PR! There's still a couple minor issues that I think need to be cleaned up, but for the most part it looks good to me.

@sandeepmistry sandeepmistry force-pushed the issue-3388-diff-target branch from 0b59ee4 to 3951673 Compare December 4, 2020 01:59
@sandeepmistry sandeepmistry changed the title [WIP] add targets support to dvc diff add targets support to dvc diff Dec 4, 2020
@sandeepmistry sandeepmistry marked this pull request as ready for review December 4, 2020 02:17
@sandeepmistry
Copy link
Copy Markdown
Contributor Author

@pmrowla thanks for the another round of suggestions and feedback - I think I've addressed everything in the last round.

I've opened PR for the documentation updates for this as well treeverse/dvc.org#2002.

Comment thread dvc/repo/diff.py Outdated
Comment thread tests/func/test_diff.py Outdated
Comment thread tests/func/test_diff.py Outdated
Comment thread tests/func/test_diff.py Outdated
Comment thread dvc/command/diff.py Outdated
@jorgeorpinel
Copy link
Copy Markdown
Contributor

Should this PR be linked to #3388 ?

Also could the [targets] argument be implicit (after the revs) instead of a --targets flag? Per #3388 (comment) and #3388 (comment)

Thanks

@efiop
Copy link
Copy Markdown
Contributor

efiop commented Dec 11, 2020

Should this PR be linked to #3388 ?

@jorgeorpinel Good point.

Also could the [targets] argument be implicit (after the revs) instead of a --targets flag? Per #3388 (comment) and #3388 (comment)

No, we can't do it right now. --targets is consistent with dvc metrics/plots diff.

@pmrowla pmrowla changed the title add targets support to dvc diff diff: add support for --targets Dec 12, 2020
@pmrowla

This comment has been minimized.

@skshetry

This comment has been minimized.

skshetry added a commit to skshetry/dvc that referenced this pull request Dec 15, 2020
RepoDependency for example don't have any path_info

See: treeverse#4938 (comment)
Related: treeverse#5035
skshetry added a commit that referenced this pull request Dec 15, 2020
RepoDependency for example don't have any path_info

See: #4938 (comment)
Related: #5035
@skshetry

This comment has been minimized.

@mergify

This comment has been minimized.

@efiop efiop force-pushed the issue-3388-diff-target branch from 1b6ee15 to 318465e Compare December 15, 2020 10:50
@pmrowla pmrowla requested a review from efiop December 15, 2020 11:22
Comment thread dvc/command/diff.py
@efiop efiop merged commit 31502ae into treeverse:master Dec 15, 2020
@efiop
Copy link
Copy Markdown
Contributor

efiop commented Dec 15, 2020

Thank you @sandeepmistry ! 🙏

dvinit

This comment was marked as spam.

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.

diff: support targets

6 participants