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 9 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
75 changes: 66 additions & 9 deletions content/docs/command-reference/root.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# root

Return the relative path to the root of the <abbr>DVC project</abbr>.
Return the relative path to the root directory of the <abbr>DVC project</abbr>.

## Synopsis

Expand All @@ -10,11 +10,12 @@ 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 for referencing a file in another
directory when working in a subdirectory of the project.
jorgeorpinel marked this conversation as resolved.
Show resolved Hide resolved

Use `dvc root` to build reusable paths to dependencies, scripts, or <abbr>data
artifacts</abbr>.
jorgeorpinel marked this conversation as resolved.
Show resolved Hide resolved

## Options

Expand All @@ -29,22 +30,78 @@ refer to a file in another directory.

```dvc
$ dvc root

.

jorgeorpinel marked this conversation as resolved.
Show resolved Hide resolved
$ cd subdir
$ dvc root

..
```

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

Simplify file references when working in a subdirectory of a <abbr>DVC
project</abbr>.
jorgeorpinel marked this conversation as resolved.
Show resolved Hide resolved

```dvc
$ dvc root

../../../

$ dvc run -d $(dvc root)/data/file.cvs ... \
python $(dvc root)/scripts/something.py
```

## Example: Output references

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
```
jorgeorpinel marked this conversation as resolved.
Show resolved Hide resolved

## Example: Other commands

Simplify other commands when working in a <abbr>DVC project</abbr>.
jorgeorpinel marked this conversation as resolved.
Show resolved Hide resolved

```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

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 \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK... I think what we need is a shell script that generates a dvc.yaml file instead of another dvc run example. Not required for this PR, so if you're not so familiar with Linux shell just leave it out for now please. Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this for now.

I looked into some related issues (#615) and examples of scripts.

These make sense within the scripting use case but instead of adding a (complicated) example that builds out a full set of stages, it would help to have the team vet a smaller example that fits the recommended usage.

-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
```