在 GitHub 上编辑

数据状态

显示在 工作区 中被 DVC 跟踪的文件和目录的变更。

有关 数据管道 的状态,请参见 dvc status

概要

描述

data status 命令显示 工作区 的状态,以及相对于最新 Git 提交(HEAD)的变更。它会告诉你哪些新变更已提交到 DVC,哪些尚未提交,哪些文件未被 DVC 和 Git 跟踪,以及哪些文件缺失于 缓存 中。

data status 可作为 git status 的补充工具。两者结合使用时,可展示仓库中所有路径的状态。

dvc data status 命令仅输出信息,不会修改或更改你的 工作区 中的任何内容。在执行 dvc commitgit commit 之前检查仓库状态是一种良好实践,以避免意外提交不打算提交的内容。

示例输出可能如下所示:

$ dvc data status
Not in cache:
  (use "dvc fetch <file>..." to download files)
        data/data.xml

DVC committed changes:
  (git commit the corresponding dvc files to update the repo)
        modified: data/features/

DVC uncommitted changes:
  (use "dvc commit <file>..." to track changes)
  (use "dvc checkout <file>..." to discard changes)
        deleted: model.pkl
(there are other changes not tracked by dvc, use "git status" to see)

dvc data status 显示多个类别的变更:

  • 不在缓存中 表示 .dvcdvc.lock 文件中存在文件哈希,但对应的 缓存 文件缺失。这可能发生在克隆 DVC 仓库后、使用 dvc pull(或 dvc fetch)下载数据之前;或在使用 dvc gc 之后。

  • 不在远程中 表示 .dvcdvc.lock 文件中存在文件哈希,但对应的 远程 文件缺失。这可能发生在向 DVC 添加新文件后、使用 dvc push 上传数据之前;或在使用 dvc gc -c 之后。

  • DVC 已提交变更 是指已 提交到 DVC 的新、修改、删除或重命名的受跟踪文件或目录。这些变更可能已准备好提交至 Git。

  • DVC 未提交变更 是指尚未 提交到 DVC 的新、修改、删除或重命名的受跟踪文件或目录。你可以使用 dvc adddvc commit 来处理这些变更。

  • 未跟踪文件 未被添加到 DVC(或 Git)中。仅在使用 --untracked-files 标志时显示。

  • 未变更文件 无任何修改。仅在使用 --unchanged 标志时显示。

默认情况下,不会显示受跟踪目录内单个文件的变更,但可通过 --granular 标志启用。

选项

  • --granular - 显示 DVC 跟踪目录内的细粒度文件级变更。注意,部分细粒度变更可能被报告为 unknown,因为 DVC 跟踪的是 目录级哈希值

  • --untracked-files - 显示未被 DVC 和 Git 跟踪的文件。

  • --unchanged - 显示未变更的 DVC 跟踪文件。

  • --not-in-remote - 显示缺失于 远程 的文件。

  • -r <name>, --remote <name> - 用于检查远程中缺失文件的 dvc remote 名称(仅在使用 --not-in-remote 时有效)。

  • --no-remote-refresh - 使用缓存的 remote 索引(不检查远程)。仅在与 --not-in-remote 一起使用时生效。

  • --json - 以易于解析的 JSON 格式输出命令结果,而非人类可读的格式。

  • -h, --help - 打印使用说明/帮助信息,然后退出。

  • -q, --quiet - 不向标准输出写入任何内容。

  • -v, --verbose - 显示详细的跟踪信息。

示例

$ dvc data status
Not in cache:
  (use "dvc fetch <file>..." to download files)
        data/data.xml

DVC committed changes:
  (git commit the corresponding dvc files to update the repo)
        modified: data/features/

DVC uncommitted changes:
  (use "dvc commit <file>..." to track changes)
  (use "dvc checkout <file>..." to discard changes)
        deleted: model.pkl
(there are other changes not tracked by dvc, use "git status" to see)

这表明 data/data.xml 缺失于缓存中,目录 data/features/ 存在 DVC 已跟踪但尚未提交到 Git 的更改,文件 model.pkl 已从 workspace 中删除。目录 data/features/ 已被修改,但未提供内部具体变更的详细信息。使用 --granular 选项可提供更多细节。

示例:完整仓库状态(包含 Git)

$ dvc data status
Not in cache:
  (use "dvc fetch <file>..." to download files)
        data/data.xml

DVC committed changes:
  (git commit the corresponding dvc files to update the repo)
        modified: data/features/

DVC uncommitted changes:
  (use "dvc commit <file>..." to track changes)
  (use "dvc checkout <file>..." to discard changes)
        deleted: model.pkl
(there are other changes not tracked by dvc, use "git status" to see)

$ git status
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   dvc.lock

no changes added to commit (use "git add" and/or "git commit -a")

dvc data statusgit status 结合使用可显示仓库的完整状态。dvc data status 显示 DVC 数据的变更,而 git status 显示对应的 dvc.lock.dvc 文件的变更(以及 Git 仓库中其他无关变更)。

示例:细粒度输出

在上述示例基础上,使用 --granular 将显示文件级别的变更信息:

$ dvc data status --granular
Not in cache:
  (use "dvc fetch <file>..." to download files)
        data/data.xml

DVC committed changes:
  (git commit the corresponding dvc files to update the repo)
        added: data/features/foo

DVC uncommitted changes:
  (use "dvc commit <file>..." to track changes)
  (use "dvc checkout <file>..." to discard changes)
        deleted: model.pkl
(there are other changes not tracked by dvc, use "git status" to see)

现在,在 DVC 已提交的变更 中,关于 data/features 的变更提供了更多信息。输出显示,data/features 中新增了一个文件:data/features/foo

示例:远程状态

$ dvc data status --not-in-remote
Not in cache:
  (use "dvc fetch <file>..." to download files)
        data/data.xml

Not in remote:
  (use "dvc push <file>..." to upload files)
        data/data.xml

DVC committed changes:
  (git commit the corresponding dvc files to update the repo)
        modified: data/features/

DVC uncommitted changes:
  (use "dvc commit <file>..." to track changes)
  (use "dvc checkout <file>..." to discard changes)
        deleted: model.pkl
(there are other changes not tracked by dvc, use "git status" to see)
内容

🐛 发现问题?告诉我们!或者修复它:

在 GitHub 上编辑

有疑问?加入我们的聊天,我们会为您提供帮助:

Discord 聊天