From 54468958fd54b356a9ed6aedb2b95a1769f145f9 Mon Sep 17 00:00:00 2001 From: Jorge Orpinel Date: Fri, 3 Jul 2020 15:18:44 -0500 Subject: [PATCH 1/3] cmd: add stage example to remove per https://github.com/iterative/dvc.org/pull/1497#issuecomment-650111941 --- content/docs/command-reference/remove.md | 45 +++++++++++++++++++++--- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/content/docs/command-reference/remove.md b/content/docs/command-reference/remove.md index 327230aa66..19b08a3771 100644 --- a/content/docs/command-reference/remove.md +++ b/content/docs/command-reference/remove.md @@ -39,10 +39,10 @@ how it can be used to replace or modify files that are tracked by DVC. - `-v`, `--verbose` - displays detailed tracing information. -## Examples +## Example: remove a tracked file (or directory) -Let's imagine we have `foo.csv` and `bar.csv` files that are already -[tracked](/doc/command-reference/add) with DVC: +Let's imagine we have `foo.csv` and `bar.csv` files, that are already +[tracked](/doc/command-reference/add) by DVC: ```dvc $ ls *.csv* @@ -55,8 +55,8 @@ $ cat .gitignore /foo.csv ``` -Remove the `foo.csv.dvc` file, and check that the data file is gone from -`.gitignore`: +This removed the `foo.csv.dvc` file, and lists `.gitignore` to double check that +the corresponding entry is gone from there: ```dvc $ dvc remove foo.csv.dvc @@ -67,3 +67,38 @@ foo.csv $ cat .gitignore /bar.csv ``` + +> The same procedure applies to tracked directories. + +## Example: remove a stage + +Let's imagine we have a stage named `train` in our +[`dvc.yaml` file](/doc/user-guide/dvc-files-and-directories#dvcyaml-file), and +corresponding files in the workspace: + +```yaml +train: + deps: + - foo.csv + outs: + - model +``` + +```dvc +$ ls +dvc.yaml dvc.lock +... foo.csv model +``` + +Running `dvc remove` on the stage name will remove this entire entry from +`dvc.yaml`, and delete its outputs: + +```dvc +$ dvc remove train +$ ls +dvc.yaml dvc.lock +... foo.csv +``` + +Notice that the dependency `foo.csv` is not removed, since it may be the output +of a previous stage. From 82cdd80ce6e4ecb1a3467e95a0df45eea352971c Mon Sep 17 00:00:00 2001 From: Jorge Orpinel Date: Fri, 3 Jul 2020 17:29:29 -0500 Subject: [PATCH 2/3] cmd: polish stage example of remove --- content/docs/command-reference/remove.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/content/docs/command-reference/remove.md b/content/docs/command-reference/remove.md index 19b08a3771..ef2d71b0b8 100644 --- a/content/docs/command-reference/remove.md +++ b/content/docs/command-reference/remove.md @@ -77,28 +77,28 @@ Let's imagine we have a stage named `train` in our corresponding files in the workspace: ```yaml -train: +test: + cmd: python train.py data.py deps: - - foo.csv + - data.csv + - train.py outs: - model ``` ```dvc $ ls -dvc.yaml dvc.lock -... foo.csv model +dvc.lock dvc.yaml foo.csv foo.csv.dvc model train.py ``` -Running `dvc remove` on the stage name will remove this entire entry from -`dvc.yaml`, and delete its outputs: +Running `dvc remove` on the stage name will remove that entry from `dvc.yaml`, +and remove its outputs from `.gitignore`. With the `--outs` option, the outputs +itself (just `model` in this example) are also removed: ```dvc -$ dvc remove train +$ dvc remove train --outs $ ls -dvc.yaml dvc.lock -... foo.csv +dvc.lock dvc.yaml foo.csv foo.csv.dvc train.py ``` -Notice that the dependency `foo.csv` is not removed, since it may be the output -of a previous stage. +Notice that the dependencies (`data.csv` and `train.py`) are not removed. From 1ab4c54c42bef06b23b1be635909513bb4cb59d4 Mon Sep 17 00:00:00 2001 From: Jorge Orpinel Date: Fri, 3 Jul 2020 17:35:24 -0500 Subject: [PATCH 3/3] cmd: complete remove desc. about .dvc file outputs and improve the file/dir example --- content/docs/command-reference/remove.md | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/content/docs/command-reference/remove.md b/content/docs/command-reference/remove.md index ef2d71b0b8..4abd4a8c52 100644 --- a/content/docs/command-reference/remove.md +++ b/content/docs/command-reference/remove.md @@ -21,7 +21,10 @@ files or directories that are tracked by DVC. It takes one or more stage names [`.dvc` files](/doc/user-guide/dvc-files-and-directories#dvc-files) as target, removes it, and optionally removes all of its outputs (`outs` field). -Note that it does not remove files from the DVC cache or remote storage (see +Note that in the case of `.dvc` file `targets`, the tracked files or directories +(`outs` in the `.dvc` file) are removed by default by this command. + +`dvc remove` does not remove files from the DVC cache or remote storage (see `dvc gc`). However, remember to run `dvc push` to save the files you actually want to use or share in the future. @@ -30,7 +33,8 @@ how it can be used to replace or modify files that are tracked by DVC. ## Options -- `--outs` - remove the outputs described in the given `targets` as well. +- `--outs` - remove the outputs of any stage `targets` as well. This is always + applied automatically for `.dvc` file targets. - `-h`, `--help` - prints the usage/help message, and exit. @@ -46,13 +50,10 @@ Let's imagine we have `foo.csv` and `bar.csv` files, that are already ```dvc $ ls *.csv* -bar.csv -bar.csv.dvc -foo.csv -foo.csv.dvc +bar.csv bar.csv.dvc foo.csv foo.csv.dvc $ cat .gitignore -/bar.csv /foo.csv +/bar.csv ``` This removed the `foo.csv.dvc` file, and lists `.gitignore` to double check that @@ -61,9 +62,7 @@ the corresponding entry is gone from there: ```dvc $ dvc remove foo.csv.dvc $ ls -bar.csv -bar.csv.dvc -foo.csv +bar.csv bar.csv.dvc foo.csv $ cat .gitignore /bar.csv ```