在 GitHub 上编辑

缓存目录

直观地设置或取消设置 缓存 目录位置(相比使用 dvc config cache),或显示当前配置的值。

概要

usage: dvc cache dir [-h] [--global | --system | --project | --local]
                     [-u] [value]

positional arguments:
  value        Path to cache directory. Relative paths are resolved
               relative to the current directory and saved to config
               relative to the config file location. If no path is
               provided, it returns the current cache directory.

描述

用于设置 cache.dir 配置选项的辅助命令。(参见 缓存目录。)与使用 dvc config cache 不同的是,dvc cache dir 会将提供的相对当前工作目录的路径(value)转换为相对于配置文件位置的路径。但如果提供的 value 是绝对路径,则保持不变。

如果没有提供路径 value,则打印当前缓存目录的路径。该值按系统、全局、项目和本地配置文件的顺序读取。

选项

  • -u, --unset - 从配置文件中移除 cache.dir 配置项。使用此标志时不要提供 value 参数。

  • --system - 使用系统配置文件(例如 /etc/xdg/dvc/config)而不是 .dvc/config

  • --global - 使用全局配置文件(例如 ~/.config/dvc/config)而不是项目的 .dvc/config

  • --project - 读取值时仅使用项目的配置文件(.dvc/config)。(写入时默认使用此项。)

  • --local - 使用 Git 忽略的本地配置文件(位于 .dvc/config.local)而不是 .dvc/config。这对于保存不想通过 Git 跟踪和共享的私有 cache.dir 值很有用。

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

  • -q, --quiet - 不向标准输出写入任何内容。如果没有问题则以 0 退出,否则以 1 退出。

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

示例:使用相对路径

$ dvc cache dir ../dir
$ cat .dvc/config
...
[cache]
    dir = ../../dir
...

../dir 已相对于 .dvc/ 目录解析,结果为 ../../dir

示例:使用绝对路径

$ dvc cache dir /path/to/dir
$ cat .dvc/config
...
[cache]
    dir = /path/to/dir
...

绝对路径 /path/to/dir 按原样保存。

示例:获取当前缓存目录

$ dvc cache dir
/home/user/dvc/.dvc/cache
内容

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

在 GitHub 上编辑

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

Discord 聊天