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

data status: exclude remote status by default #9411

Merged
merged 1 commit into from
May 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions dvc/commands/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def run(self) -> int:
status = self.repo.data_status(
granular=self.args.granular,
untracked_files=self.args.untracked_files,
not_in_remote=self.args.not_in_remote,
remote_refresh=self.args.remote_refresh,
)

Expand Down Expand Up @@ -244,10 +245,16 @@ def add_parser(subparsers, parent_parser):
help="Show untracked files.",
)
data_status_parser.add_argument(
"--remote-refresh",
"--not-in-remote",
action="store_true",
default=False,
help="Refresh remote index.",
help="Show files not in remote.",
)
data_status_parser.add_argument(
"--no-remote-refresh",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@efiop I think refreshing is a more reasonable default because it is probably more intuitive and expected unless users are thinking deeply about how it compares to git. However, if you have a reason why you strongly prefer to rely on the index by default, I'm open to changing this back as long as we also keep the --not-in-remote option.

Copy link
Member

Choose a reason for hiding this comment

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

If it's an explicit flag, fetching latest changes make sense to me. I'm okay with showing a hint/summary to dvc push if needed by default.

dest="remote_refresh",
action="store_false",
help="Use cached remote index (don't check remote).",
)
data_status_parser.set_defaults(func=CmdDataStatus)

Expand Down
1 change: 0 additions & 1 deletion dvc/repo/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ def _diff_index_to_wtree(repo: "Repo", **kwargs: Any) -> Dict[str, List[str]]:
repo.index.data["repo"],
workspace,
not_in_cache=True,
not_in_remote=True,
**kwargs,
)

Expand Down
12 changes: 10 additions & 2 deletions tests/func/test_data_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,15 +402,23 @@ def test_missing_remote_cache(M, tmp_dir, dvc, scm, local_remote):
tmp_dir.dvc_gen({"dir": {"foo": "foo", "bar": "bar"}})
tmp_dir.dvc_gen("foobar", "foobar")

assert dvc.data_status(untracked_files="all") == {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@efiop Do we have a way to test remote refresh?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not really and I don't think we need to.

assert dvc.data_status() == {
**EMPTY_STATUS,
"committed": {"added": M.unordered("foobar", join("dir", ""))},
"git": M.dict(),
}

assert dvc.data_status(untracked_files="all", not_in_remote=True) == {
**EMPTY_STATUS,
"untracked": M.unordered("foobar.dvc", "dir.dvc", ".gitignore"),
"committed": {"added": M.unordered("foobar", join("dir", ""))},
"not_in_remote": M.unordered("foobar", join("dir", "")),
"git": M.dict(),
}

assert dvc.data_status(granular=True, untracked_files="all") == {
assert dvc.data_status(
granular=True, untracked_files="all", not_in_remote=True
) == {
**EMPTY_STATUS,
"untracked": M.unordered("foobar.dvc", "dir.dvc", ".gitignore"),
"committed": {
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/command/test_data_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def test_cli(dvc, mocker, mocked_status):
assert cmd.run() == 0
status.assert_called_once_with(
untracked_files="all",
remote_refresh=False,
not_in_remote=False,
remote_refresh=True,
granular=True,
)

Expand Down