From f8b9e667919615a83e9165be7a18b3c309029d95 Mon Sep 17 00:00:00 2001 From: dberenbaum Date: Fri, 5 May 2023 12:00:47 -0400 Subject: [PATCH] data status: exclude remote status by default --- dvc/commands/data.py | 11 +++++++++-- dvc/repo/data.py | 1 - tests/func/test_data_status.py | 12 ++++++++++-- tests/unit/command/test_data_status.py | 3 ++- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/dvc/commands/data.py b/dvc/commands/data.py index 2cd92189a1..2c09cf6cf9 100644 --- a/dvc/commands/data.py +++ b/dvc/commands/data.py @@ -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, ) @@ -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", + dest="remote_refresh", + action="store_false", + help="Use cached remote index (don't check remote).", ) data_status_parser.set_defaults(func=CmdDataStatus) diff --git a/dvc/repo/data.py b/dvc/repo/data.py index 5f8cfcde3c..22fadfa4f5 100644 --- a/dvc/repo/data.py +++ b/dvc/repo/data.py @@ -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, ) diff --git a/tests/func/test_data_status.py b/tests/func/test_data_status.py index b9cb1edeae..98f103fc41 100644 --- a/tests/func/test_data_status.py +++ b/tests/func/test_data_status.py @@ -402,7 +402,13 @@ 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") == { + 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", ""))}, @@ -410,7 +416,9 @@ def test_missing_remote_cache(M, tmp_dir, dvc, scm, local_remote): "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": { diff --git a/tests/unit/command/test_data_status.py b/tests/unit/command/test_data_status.py index 6a1f388bdf..1e7e8cb3e8 100644 --- a/tests/unit/command/test_data_status.py +++ b/tests/unit/command/test_data_status.py @@ -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, )