Update duplicate output error msg#9138
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #9138 +/- ##
========================================
Coverage 92.86% 92.86%
========================================
Files 458 458
Lines 37013 37028 +15
Branches 4355 5350 +995
========================================
+ Hits 34373 34387 +14
Misses 2114 2114
- Partials 526 527 +1
... and 1 file with indirect coverage changes 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 in Codecov by Sentry. |
This comment was marked as outdated.
This comment was marked as outdated.
omesser
left a comment
There was a problem hiding this comment.
Can be compacted a bit more maybe if we tradeoff some "accuracy", e.g.
dvc removemessage can be unified- maybe the multiline
'\t-'variant is not needed
But is fine either way imo, approving
a2927e5 to
9c82ebf
Compare
| try: | ||
| self.repo.check_graph(stages={stage}) | ||
| except OutputDuplicationError as exc: | ||
| # Don't include the stage currently being added. | ||
| exc.stages.remove(stage) | ||
| raise OutputDuplicationError(exc.output, exc.stages) from None |
There was a problem hiding this comment.
Would be nice to add a test for this
There was a problem hiding this comment.
Any suggestions for where to add it?
There was a problem hiding this comment.
Probably in tests/fun/test_add, something like: https://github.com/iterative/dvc/blob/121d56b7391f5325e5eb6ff41448980f0ede00df/tests/func/test_add.py#L749-L753 or even just update that one and use match with the expected exception message
There was a problem hiding this comment.
Does the message vary if the order is different from the one in the test (i.e. you run dvc add first)?
There was a problem hiding this comment.
Yes it does. This PR doesn't change the error for dvc add, only for dvc stage add, so not sure if it makes sense to put it there. Had trouble finding any tests about dvc stage add beyond testing the cmd args.
There was a problem hiding this comment.
Ok. I understand.
From a quick look, I think I would personally add it to tests/func/test_stage.py then. Like:
def test_stage_add_duplicated_output(tmp_dir, dvc):
tmp_dir.dvc_gen("foo", "foo")
dvc.add("foo")
with pytest.raises(
OutputDuplicationError,
match="Use `dvc remove foo.dvc` to stop tracking the overlapping output."
):
dvc.stage.add(name="duplicated", cmd="echo bar > foo", outs=["foo"])But I am also confused about where the logic for StageLoad.create is/should be tested cc @skshetry
There was a problem hiding this comment.
Added the test you suggested @daavoo. It makes sense to me.
Thanks @omesser. Tried to clean this up a bit. |
7489ca4 to
fbc86a1
Compare
fbc86a1 to
8ef7c62
Compare
Fixes #8986
Before this PR:
After this PR: