From 826019177d26594ab1d37ba5e33e4eaef7265cac Mon Sep 17 00:00:00 2001 From: Jeremy DesRoches Date: Wed, 29 Jul 2020 20:53:42 +0800 Subject: [PATCH 1/3] Clarifies motivation and description, adds relevant examples --- content/docs/command-reference/root.md | 75 ++++++++++++++++++++++++-- 1 file changed, 70 insertions(+), 5 deletions(-) diff --git a/content/docs/command-reference/root.md b/content/docs/command-reference/root.md index 2b4c29deae..ce7854ee5a 100644 --- a/content/docs/command-reference/root.md +++ b/content/docs/command-reference/root.md @@ -10,11 +10,15 @@ usage: dvc root [-h] [-q | -v] ## Description -This command returns the path to the root directory of the DVC -project, relative to the current working directory. It can be used to -build a path to a dependency, script, or data artifact, for -example. Useful when working in a subdirectory of the project, and needing to -refer to a file in another directory. +The `dvc root` command returns the path to the root directory of the DVC +project, relative to the current working directory. + +Using `dvc root`, you can build a path to a dependency, script, or data +artifact using `dvc run` from any subdirectory of a DVC +project. + +You can also use `dvc root` to simplify other commands when working in a +DVC project. ## Options @@ -40,6 +44,9 @@ $ dvc root ## Example: Referencing files +Use `dvc root` to simplify file references when working in a subdirectory of a +DVC project. + ```dvc $ dvc root @@ -48,3 +55,61 @@ $ dvc root $ dvc run -d $(dvc root)/data/file.cvs ... \ python $(dvc root)/scripts/something.py ``` + +## Example: Output references + +Use `dvc root` to simplify output file or directory references. + +```dvc +$ dvc root + +../../../ + +$ dvc get -o $(dvc root)/root-model.pkl \ + https://github.com/iterative/example-get-started model.pkl +``` + +## Example: Other commands + +Use `dvc root` to simplify other commands when working in a DVC +project. + +```dvc +$ dvc root + +../.. + +$ tree $(dvc root)/data/ +../../data/ +├── data.xml +├── data.xml.dvc +... +└── prepared + ├── test.tsv + └── train.tsv +``` + +## Example: Build reusable paths + +Use `dvc root` to build reusable paths to dependencies, scripts, or data +artifacts from separate stages and subdirectories. + +```dvc +$ cd more_stages/ +$ dvc run -n process_data \ + -d data.in \ + -d $(dvc root)/process_data.py \ + -o result.out \ + python process_data.py data.in result.out +$ tree .. +. +├── dvc.yaml +├── dvc.lock +├── process_data.py +├── ... +└── more_stages/ + ├── data.in + ├── dvc.lock + ├── dvc.yaml + └── result.out +``` From ec653092345e6f31f36827cf00251a9f146370f7 Mon Sep 17 00:00:00 2001 From: Jeremy DesRoches Date: Thu, 30 Jul 2020 10:42:10 +0800 Subject: [PATCH 2/3] Returned to single paragraph, adjusts style to comments --- content/docs/command-reference/root.md | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/content/docs/command-reference/root.md b/content/docs/command-reference/root.md index ce7854ee5a..e3fa0f5703 100644 --- a/content/docs/command-reference/root.md +++ b/content/docs/command-reference/root.md @@ -10,15 +10,7 @@ usage: dvc root [-h] [-q | -v] ## Description -The `dvc root` command returns the path to the root directory of the DVC -project, relative to the current working directory. - -Using `dvc root`, you can build a path to a dependency, script, or data -artifact using `dvc run` from any subdirectory of a DVC -project. - -You can also use `dvc root` to simplify other commands when working in a -DVC project. +Returns the path to the root directory of the DVC project, relative to the current working directory. Useful when working in a subdirectory of the project, and you need to refer to a file in another directory. Use it in files and commands to build a path to a dependency, script, or data artifact. ## Options From 46c4a123190980175f40b4a1d72fe200119a1016 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Thu, 30 Jul 2020 02:42:34 +0000 Subject: [PATCH 3/3] Restyled by prettier --- content/docs/command-reference/root.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/content/docs/command-reference/root.md b/content/docs/command-reference/root.md index e3fa0f5703..ac0849b06a 100644 --- a/content/docs/command-reference/root.md +++ b/content/docs/command-reference/root.md @@ -10,7 +10,11 @@ usage: dvc root [-h] [-q | -v] ## Description -Returns the path to the root directory of the DVC project, relative to the current working directory. Useful when working in a subdirectory of the project, and you need to refer to a file in another directory. Use it in files and commands to build a path to a dependency, script, or data artifact. +Returns the path to the root directory of the DVC project, relative +to the current working directory. Useful when working in a subdirectory of the +project, and you need to refer to a file in another directory. Use it in files +and commands to build a path to a dependency, script, or data +artifact. ## Options