Return the relative path to the root directory of the DVC project.
usage: dvc root [-h] [-q | -v]
Returns the path to the root directory of the DVC project, relative
to the current working directory. dvc root
is useful for referencing a file in
another directory when working in a subdirectory of the project.
Use this command to build fixed paths to dependencies, files, or stage
outputs. This is useful when creating shell scripts that generate
dvc.yaml
files programmatically or with the dvc run
helper.
-h
, --help
- prints the usage/help message, and exit.-q
, --quiet
- do not write anything to standard output. Exit with 0 if no
problems arise, otherwise 1.-v
, --verbose
- displays detailed tracing information.$ dvc root
.
$ mkdir subdir
$ cd subdir
$ dvc root
..
When working in a subdirectory of a DVC project, simplify file references by making all paths relative to the root directory.
$ dvc root
../../../
$ dvc run -d $(dvc root)/data/file.cvs ... \
python $(dvc root)/scripts/something.py
The same can be applied to non-DVC commands:
$ dvc root
../..
$ tree $(dvc root)/data/
../../data/
โโโ data.xml
โโโ data.xml.dvc
...