mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-09 23:10:24 +01:00
add: tweak stage overlap error message (#9514)
* add: tweak stage overlap error message * add: instructions for how to fix overlap error
This commit is contained in:
+10
-1
@@ -32,6 +32,12 @@ if TYPE_CHECKING:
|
||||
from dvc.stage import Stage
|
||||
|
||||
|
||||
PIPELINE_TRACKED_UPDATE_FMT = (
|
||||
"cannot update {out!r}: overlaps with an output of {stage} in '{path}'.\n"
|
||||
"Run the pipeline or use 'dvc commit' to force update it."
|
||||
)
|
||||
|
||||
|
||||
class StageInfo(NamedTuple):
|
||||
stage: "Stage"
|
||||
output_exists: bool
|
||||
@@ -91,7 +97,10 @@ def get_or_create_stage(
|
||||
(out_obj,) = repo.find_outs_by_path(target, strict=False)
|
||||
stage = out_obj.stage
|
||||
if not stage.is_data_source:
|
||||
raise DvcException(f"cannot update {out!r}: not a data source")
|
||||
msg = PIPELINE_TRACKED_UPDATE_FMT.format(
|
||||
out=out, stage=stage, path=stage.relpath
|
||||
)
|
||||
raise DvcException(msg)
|
||||
return StageInfo(stage, output_exists=True)
|
||||
except OutputNotFoundError:
|
||||
stage = repo.stage.create(
|
||||
|
||||
@@ -722,7 +722,11 @@ def test_add_optimization_for_hardlink_on_empty_files(tmp_dir, dvc, mocker):
|
||||
def test_try_adding_pipeline_tracked_output(tmp_dir, dvc, run_copy):
|
||||
tmp_dir.dvc_gen("foo", "foo")
|
||||
run_copy("foo", "bar", name="copy-foo-bar")
|
||||
with pytest.raises(DvcException, match="cannot update 'bar': not a data source"):
|
||||
msg = (
|
||||
"cannot update 'bar': overlaps with an output of stage: 'copy-foo-bar' in "
|
||||
"'dvc.yaml'.\nRun the pipeline or use 'dvc commit' to force update it."
|
||||
)
|
||||
with pytest.raises(DvcException, match=msg):
|
||||
dvc.add("bar")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user