iterative / dvc

🦉 Data Versioning and ML Experiments
https://dvc.org
Apache License 2.0
13.71k stars 1.18k forks source link

diff: unexpected error when rev_a & rev_b point to the same revision #9604

Closed george-kuanli-peng closed 1 year ago

george-kuanli-peng commented 1 year ago

Description

dvc diff <rev_a> <rev_b> outputs ERROR: unexpected error - '<rev_a>' when and happen to point to the same revision.

Reproduce

There is a Git repo with 4 branches:

Run the following commands:

  1. dvc diff main new-main
  2. dvc diff main new-1
  3. dvc diff new-main new-2

Expected

All the commands should work.

However, only the 1st command work and the others fail with unexpected error:

root@dc53a8a4f5c3:~/data/my-ds/VC-Project-Dev# dvc diff main new-main
Added:
    data/raw/new_dir/f1.txt

Deleted:
    data/raw/new_dir1/new.txt
    data/rsc/images/f1.txt

Modified:
    data/

files summary: 1 added, 2 deleted
root@dc53a8a4f5c3:~/data/my-ds/VC-Project-Dev# dvc diff main new-1
ERROR: unexpected error - 'main'                                      

Having any troubles? Hit us up at https://dvc.org/support, we are always happy to help!
root@dc53a8a4f5c3:~/data/my-ds/VC-Project-Dev# dvc diff new-main new-2
ERROR: unexpected error - 'new-main'                                  

Having any troubles? Hit us up at https://dvc.org/support, we are always happy to help!

With verbose output:

# dvc diff -v new-main new-2
2023-06-14 10:03:55,347 DEBUG: v3.0.0 (pip), CPython 3.8.12 on Linux-5.4.0-84-generic-x86_64-with-glibc2.10
2023-06-14 10:03:55,347 DEBUG: command: /opt/conda/bin/dvc diff -v new-main new-2
2023-06-14 10:03:56,359 ERROR: unexpected error - 'new-main'          
Traceback (most recent call last):
  File "/opt/conda/lib/python3.8/site-packages/dvc/cli/__init__.py", line 209, in main
    ret = cmd.do_run()
  File "/opt/conda/lib/python3.8/site-packages/dvc/cli/command.py", line 26, in do_run
    return self.run()
  File "/opt/conda/lib/python3.8/site-packages/dvc/commands/diff.py", line 123, in run
    diff = self.repo.diff(self.args.a_rev, self.args.b_rev, self.args.targets)
  File "/opt/conda/lib/python3.8/site-packages/dvc/repo/__init__.py", line 64, in wrapper
    return f(repo, *args, **kwargs)
  File "/opt/conda/lib/python3.8/site-packages/dvc/repo/diff.py", line 159, in diff
    old = indexes[a_rev]
KeyError: 'new-main'

2023-06-14 10:03:56,573 DEBUG: Version info for developers:
DVC version: 3.0.0 (pip)
------------------------
Platform: Python 3.8.12 on Linux-5.4.0-84-generic-x86_64-with-glibc2.10
Subprojects:
        dvc_data = 1.11.0
        dvc_objects = 0.23.0
        dvc_render = 0.5.3
        dvc_task = 0.3.0
        scmrepo = 1.0.3
Supports:
        http (aiohttp = 3.8.4, aiohttp-retry = 2.8.3),
        https (aiohttp = 3.8.4, aiohttp-retry = 2.8.3),
        s3 (s3fs = 2023.6.0, boto3 = 1.26.76)
Config:
        Global: /mlsteam/.config/dvc
        System: /etc/xdg/dvc
Cache types: <https://error.dvc.org/no-dvc-cache>
Caches: local
Remotes: s3
Workspace directory: xfs on /dev/sdb1
Repo: dvc, git
Repo.site_cache_dir: /var/tmp/dvc/repo/91479b46e9e0a07ae16a57a5b4209cf5

Having any troubles? Hit us up at https://dvc.org/support, we are always happy to help!
2023-06-14 10:03:56,577 DEBUG: Analytics is disabled.

Environment information

Output of dvc doctor:

# dvc doctor
DVC version: 3.0.0 (pip)
------------------------
Platform: Python 3.8.12 on Linux-5.4.0-84-generic-x86_64-with-glibc2.10
Subprojects:
        dvc_data = 1.11.0
        dvc_objects = 0.23.0
        dvc_render = 0.5.3
        dvc_task = 0.3.0
        scmrepo = 1.0.3
Supports:
        http (aiohttp = 3.8.4, aiohttp-retry = 2.8.3),
        https (aiohttp = 3.8.4, aiohttp-retry = 2.8.3),
        s3 (s3fs = 2023.6.0, boto3 = 1.26.76)
Config:
        Global: /mlsteam/.config/dvc
        System: /etc/xdg/dvc
Cache types: <https://error.dvc.org/no-dvc-cache>
Caches: local
Remotes: s3
Workspace directory: xfs on /dev/sdb1
Repo: dvc, git
Repo.site_cache_dir: /var/tmp/dvc/repo/91479b46e9e0a07ae16a57a5b4209cf5
efiop commented 1 year ago

Looks like our brancher concats the revs into "main,newmain", which might be intended in some other place, but obviously is not inteded here. Taking a closer look...