treeverse / treeverse/dvc

dvc stage add --force: Only adds new outs to .gitignore, doesn't remove unused outs

Open
#6,036 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A: pipelines bug p2-medium research
Dominant language
Python
Stars
15.9k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

Bug Report

Description

According to the documentation I should use dvc stage add --force when I want to update a stage. However the .gitignore file only gets updated with new output files and old output files aren't removed from .gitignore.

Reproduce
  1. dvc stage add -n test_stage -o file1 -o file2 python test_script.py
  2. View the produced .gitignore. It should contain the following
/file1
/file2
  1. dvc stage add --force -n test_stage -o file1 -o file3 python test_script.py
  2. View the produced .gitignore. It should contain the following
/file1
/file2
/file3
Expected

Updating a stage via dvc stage add --force should remove outs from the stage that are no longer included. Using dvc remove does do this.

I'm expecting the gitignore file to look like this after step 4

/file1
/file3
Environment information

Output of dvc doctor:

DVC version: 2.0.18 (conda)
---------------------------------
Platform: Python 3.9.4 on macOS-10.15.7-x86_64-i386-64bit
Supports: http, https
Cache types: reflink, hardlink, symlink
Cache directory: apfs on /dev/disk1s5
Caches: local
Remotes: None
Workspace directory: apfs on /dev/disk1s5
Repo: dvc, git

Additional Information (if any):

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the implementation and tests for dvc stage add --force, then reproduce the four command-line steps from the issue. Confirm that replacing file2 with file3 removes /file2 while retaining /file1 and adding /file3 in .gitignore.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.