| 36 | """ |
| 37 | |
| 38 | def __init__(self, output: str, stages: set["Stage"]): |
| 39 | from funcy import first |
| 40 | |
| 41 | assert isinstance(output, str) |
| 42 | assert all(hasattr(stage, "relpath") for stage in stages) |
| 43 | if len(stages) == 1: |
| 44 | stage = first(stages) |
| 45 | msg = ( |
| 46 | f"output '{output}' is already specified in {stage}." |
| 47 | f"\nUse `dvc remove {stage.addressing}` to stop tracking the " |
| 48 | "overlapping output." |
| 49 | ) |
| 50 | else: |
| 51 | stage_names = "\n".join(["\t- " + s.addressing for s in stages]) |
| 52 | msg = ( |
| 53 | f"output '{output}' is specified in:\n{stage_names}" |
| 54 | "\nUse `dvc remove` with any of the above targets to stop tracking the " |
| 55 | "overlapping output." |
| 56 | ) |
| 57 | super().__init__(msg) |
| 58 | self.stages = stages |
| 59 | self.output = output |
| 60 | |
| 61 | |
| 62 | class OutputNotFoundError(DvcException): |