Skip to content

provide helpful message on output duplications #4010

@skshetry

Description

@skshetry

Bug Report

Repro

$ cat dvc.yaml
stages:
  plot-metrics:
    cmd: cp metrics-temp.csv metrics.csv
    deps:
    - metrics-temp.csv
    plots:
    - metrics.csv
  generate-foo:
    cmd: echo 'foo0\nfoo1' > foo && cat foo
    outs:
    - foo
    - metrics.csv  # notice the output duplication
$ python -c '
import dvc.api

with dvc.api.open("metrics.csv") as f:
  print(f.read())'

Traceback (most recent call last):
  File "/home/saugat/repos/iterative/dvc/dvc/repo/__init__.py", line 585, in open_by_relpath
    remote=remote,
  File "/home/saugat/repos/iterative/dvc/dvc/repo/tree.py", line 257, in open
    path, mode=mode, encoding=encoding, **kwargs
  File "/home/saugat/repos/iterative/dvc/dvc/repo/tree.py", line 67, in open
    raise IsADirectoryError
IsADirectoryError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<string>", line 4, in <module>
  File "/home/saugat/.pyenv/versions/3.6.6/lib/python3.6/contextlib.py", line 81, in __enter__
    return next(self.gen)
  File "/home/saugat/repos/iterative/dvc/dvc/api.py", line 74, in _open
    path, remote=remote, mode=mode, encoding=encoding
  File "/home/saugat/.pyenv/versions/3.6.6/lib/python3.6/contextlib.py", line 81, in __enter__
    return next(self.gen)
  File "/home/saugat/repos/iterative/dvc/dvc/repo/__init__.py", line 591, in open_by_relpath
    raise DvcIsADirectoryError(f"'{path}' is a directory") from exc
dvc.exceptions.IsADirectoryError: '/home/saugat/dvc_try/test_multistage/metrics.csv' is a directory

Similar things happens on plots diff (message is cryptic):

$ dvc plots diff -t metrics.csv HEAD~
ERROR: unexpected error

Having any troubles? Hit us up at https://dvc.org/support, we are always happy to help!
$ dvc plots diff -t metrics.csv HEAD~ -v
2020-06-10 18:28:50,571 ERROR: unexpected error
------------------------------------------------------------
Traceback (most recent call last):
  File "/home/saugat/repos/iterative/dvc/dvc/main.py", line 53, in main
    ret = cmd.run()
  File "/home/saugat/repos/iterative/dvc/dvc/command/plots.py", line 53, in run
    plots = self._func(targets=self.args.targets, props=self._props())
  File "/home/saugat/repos/iterative/dvc/dvc/command/plots.py", line 88, in _func
    return self.repo.plots.diff(*args, revs=self.args.revisions, **kwargs)
  File "/home/saugat/repos/iterative/dvc/dvc/repo/plots/__init__.py", line 82, in diff
    return diff(self.repo, *args, **kwargs)
  File "/home/saugat/repos/iterative/dvc/dvc/repo/plots/diff.py", line 12, in diff
    *args, revs=_revisions(revs, repo.scm.is_dirty()), **kwargs
  File "/home/saugat/repos/iterative/dvc/dvc/repo/plots/__init__.py", line 65, in show
    data = self.collect(targets, revs)
  File "/home/saugat/repos/iterative/dvc/dvc/repo/plots/__init__.py", line 41, in collect
    with tree.open(datafile) as fd:
  File "/home/saugat/repos/iterative/dvc/dvc/repo/tree.py", line 257, in open
    path, mode=mode, encoding=encoding, **kwargs
  File "/home/saugat/repos/iterative/dvc/dvc/repo/tree.py", line 67, in open
    raise IsADirectoryError
IsADirectoryError
------------------------------------------------------------

Please provide information about your setup

Output of dvc version:

$ dvc version
dvc version
DVC version: 1.0.0a10+91a719
Python version: 3.6.6
Platform: Linux-5.5.2-arch1-1-x86_64-with-arch
Binary: False
Package: None
Supported remotes: azure, gdrive, gs, hdfs, http, https, s3, ssh, oss
Cache: reflink - not supported, hardlink - supported, symlink - supported
Filesystem type (cache directory): ('ext4', '/dev/sda9')
Repo: dvc, git
Filesystem type (workspace): ('ext4', '/dev/sda9')

Additional Information (if any):

Expected Behavior

Complain that output is duplicated. The error message is not helpful at all.

We do provide helpful message on run/repro/add/imp, but not on these checkouts.
Also, we should not throw out error on dvc checkout foo as it will affect workflow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugDid we break something?enhancementEnhances DVCp2-mediumMedium priority, should be done, but less importantuiuser interface / interaction

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions