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

fix exception on dvc stage add with non-existing dirs #8645

Closed
wants to merge 1 commit into from

Conversation

dtrifiro
Copy link
Contributor

@dtrifiro dtrifiro commented Nov 30, 2022

Running dvc stage add <..> -o nonexisting_dir/file would fail with a FileNotFoundError for the .gitignore file in nonexisting_dir. This happened because the outputs are added to the .gitignore when creating the stage.

To reproduce:

mkdir tmp
cd tmp

git init
dvc init
dvc stage add -f -n prepare \
                -p prepare.seed,prepare.split \
                -d src/prepare.py -d data/data.xml \
                -o data/prepared --pdb \
                python src/prepare.py data/data.xml

this will raise FileNotFoundError: data/.gitignore

fixes #5802

running `dvc stage add <..> -o nonexisting_dir/file` would fail
with a `FileNotFoundError` for the `.gitignore` file in `nonexisting_dir`.
This happened because the outputs are added to the `.gitignore` when
creating the stage.
@codecov
Copy link

codecov bot commented Nov 30, 2022

Codecov Report

Base: 94.13% // Head: 94.13% // No change to project coverage 👍

Coverage data is based on head (7ce689a) compared to base (6fdd667).
Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8645   +/-   ##
=======================================
  Coverage   94.13%   94.13%           
=======================================
  Files         435      435           
  Lines       33335    33335           
  Branches     4690     4690           
=======================================
  Hits        31379    31379           
  Misses       1528     1528           
  Partials      428      428           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@dberenbaum
Copy link
Collaborator

😄 See iterative/example-repos-dev#153. Happy to close mine for this. I went with ignoring the failure instead of creating the dirs, but I'm fine with either.

@dtrifiro
Copy link
Contributor Author

dtrifiro commented Dec 1, 2022

I like your approach best, closing this in favour of #8644

@dtrifiro dtrifiro closed this Dec 1, 2022
@dtrifiro dtrifiro deleted the fix-stage-add-crash branch December 1, 2022 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

stage add: fails with dirs that will be created later by the cmd(s)
2 participants