Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dvc root command reference motivation and examples #1637

Merged
merged 19 commits into from
Jul 31, 2020
Merged
Changes from 5 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
8260191
Clarifies motivation and description, adds relevant examples
jeremydesroches Jul 29, 2020
ec65309
Returned to single paragraph, adjusts style to comments
jeremydesroches Jul 30, 2020
844f281
Returned to single paragraph, adjusts style to comments
jeremydesroches Jul 30, 2020
cae263c
Merge branch 'cmdroot' of https://github.com/jeremydesroches/dvc.org …
jeremydesroches Jul 30, 2020
3fa33d5
Fixes my merge mistake
jeremydesroches Jul 30, 2020
7a630b5
Removes repeated references to dvc root from examples
jeremydesroches Jul 30, 2020
f0ef6e8
Adds "root directory" to short intro
jeremydesroches Jul 30, 2020
8952e4e
Adds command name and splits description to two paragraphs
jeremydesroches Jul 30, 2020
8bd6c61
removes extra spacing from examples
jeremydesroches Jul 30, 2020
6dc5f64
Update content/docs/command-reference/root.md
jorgeorpinel Jul 30, 2020
24d5ed8
Update content/docs/command-reference/root.md
jorgeorpinel Jul 30, 2020
8474156
Update content/docs/command-reference/root.md
jeremydesroches Jul 31, 2020
9c82fc8
Removes extra examples, updates example titles and descriptions
jeremydesroches Jul 31, 2020
b05473b
Updates description to expand scripting use case
jeremydesroches Jul 31, 2020
f005507
Update content/docs/command-reference/root.md
jorgeorpinel Jul 31, 2020
f8b08e6
Update content/docs/command-reference/root.md
jorgeorpinel Jul 31, 2020
a7d0f27
Update content/docs/command-reference/root.md
jorgeorpinel Jul 31, 2020
070cf40
Update content/docs/command-reference/root.md
jorgeorpinel Jul 31, 2020
9496822
Update content/docs/command-reference/root.md
jorgeorpinel Jul 31, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 66 additions & 5 deletions content/docs/command-reference/root.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ usage: dvc root [-h] [-q | -v]

## Description

This command returns the path to the root directory of the <abbr>DVC
project</abbr>, relative to the current working directory. It can be used to
build a path to a dependency, script, or <abbr>data artifact</abbr>, for
example. Useful when working in a subdirectory of the project, and needing to
refer to a file in another directory.
Returns the path to the root directory of the <abbr>DVC project</abbr>, relative
jorgeorpinel marked this conversation as resolved.
Show resolved Hide resolved
to the current working directory. Useful when working in a subdirectory of the
jorgeorpinel marked this conversation as resolved.
Show resolved Hide resolved
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 <abbr>data
jorgeorpinel marked this conversation as resolved.
Show resolved Hide resolved
artifact</abbr>.

## Options

Expand All @@ -40,6 +40,9 @@ $ dvc root

## Example: Referencing files
jeremydesroches marked this conversation as resolved.
Show resolved Hide resolved

Use `dvc root` to simplify file references when working in a subdirectory of a
<abbr>DVC project</abbr>.

```dvc
$ dvc root

jorgeorpinel marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -48,3 +51,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 <abbr>DVC
project</abbr>.

```dvc
$ dvc root

../..

$ tree $(dvc root)/data/
../../data/
├── data.xml
├── data.xml.dvc
...
└── prepared
├── test.tsv
└── train.tsv
jorgeorpinel marked this conversation as resolved.
Show resolved Hide resolved
```

## Example: Build reusable paths

Use `dvc root` to build reusable paths to dependencies, scripts, or <abbr>data
artifacts</abbr> 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
```