Skip to content

plots diff: handle custom templates missing from new revisions #9188

@dberenbaum

Description

@dberenbaum

Bug Report

Description

dvc plots diff will fail if there is a custom template used in an old revision but missing in the workspace.

Reproduce

  1. Clone https://github.com/iterative/vscode-dvc-demo.
  2. Run $ dvc plots diff -v 9460ec.

Output:

2023-03-15 09:19:04,191 DEBUG: v2.48.1.dev3+gff11f9d7b, CPython 3.10.2 on macOS-13.2.1-arm64-arm-64bit
2023-03-15 09:19:04,191 DEBUG: command: /Users/dave/miniforge3/envs/dvc/bin/dvc plots diff -v 9460ec
2023-03-15 09:19:04,919 ERROR: unexpected error - Template 'jitter.json' not found.
Traceback (most recent call last):
  File "/Users/dave/Code/dvc/dvc/cli/__init__.py", line 210, in main
    ret = cmd.do_run()
  File "/Users/dave/Code/dvc/dvc/cli/command.py", line 26, in do_run
    return self.run()
  File "/Users/dave/Code/dvc/dvc/commands/plots.py", line 126, in run
    renderers = match_defs_renderers(
  File "/Users/dave/Code/dvc/dvc/render/match.py", line 105, in match_defs_renderers
    renderers.append(renderer_cls(plot_datapoints, renderer_id, **final_props))
  File "/Users/dave/Code/dvc-render/src/dvc_render/vega.py", line 40, in __init__
    self.template = get_template(
  File "/Users/dave/Code/dvc-render/src/dvc_render/vega_templates.py", line 616, in get_template
    raise TemplateNotFoundError(template)
dvc_render.vega_templates.TemplateNotFoundError: Template 'jitter.json' not found.

2023-03-15 09:19:04,940 DEBUG: Removing '/Users/dave/Code/.J3EFmnX47iCQFmkchxjJTF.tmp'
2023-03-15 09:19:04,940 DEBUG: Removing '/Users/dave/Code/.J3EFmnX47iCQFmkchxjJTF.tmp'
2023-03-15 09:19:04,940 DEBUG: Removing '/Users/dave/Code/.J3EFmnX47iCQFmkchxjJTF.tmp'
2023-03-15 09:19:04,940 DEBUG: Removing '/Users/dave/Code/vscode-dvc-demo/.dvc/cache/.6uCnSJiUrFHfmRkNmVj2HC.tmp'
2023-03-15 09:19:04,941 DEBUG: Version info for developers:
DVC version: 2.48.1.dev3+gff11f9d7b
-----------------------------------
Platform: Python 3.10.2 on macOS-13.2.1-arm64-arm-64bit
Subprojects:
        dvc_data = 0.43.0
        dvc_objects = 0.21.1
        dvc_render = 0.2.1.dev10+g1cdf98f
        dvc_task = 0.2.0
        scmrepo = 0.1.15
Supports:
        azure (adlfs = 2022.9.1, knack = 0.9.0, azure-identity = 1.7.1),
        gdrive (pydrive2 = 1.15.0),
        gs (gcsfs = 2022.11.0),
        hdfs (fsspec = 2022.11.0+0.gacad158.dirty, pyarrow = 7.0.0),
        http (aiohttp = 3.8.1, aiohttp-retry = 2.8.3),
        https (aiohttp = 3.8.1, aiohttp-retry = 2.8.3),
        oss (ossfs = 2021.8.0),
        s3 (s3fs = 2022.11.0+6.g804057f.dirty, boto3 = 1.24.59),
        ssh (sshfs = 2023.1.0),
        webdav (webdav4 = 0.9.4),
        webdavs (webdav4 = 0.9.4),
        webhdfs (fsspec = 2022.11.0+0.gacad158.dirty)
Cache types: reflink, hardlink, symlink
Cache directory: apfs on /dev/disk3s1s1
Caches: local
Remotes: https, s3
Workspace directory: apfs on /dev/disk3s1s1
Repo: dvc, git
Repo.site_cache_dir: /Library/Caches/dvc/repo/43e72f9536dffe729386091316011d74

Having any troubles? Hit us up at https://dvc.org/support, we are always happy to help!
2023-03-15 09:19:04,944 DEBUG: Analytics is disabled.

Expected

  1. Ignore any plots for which the custom template is needed and render the remaining plots.
  2. Even better would be to use the custom template from the old revisions where needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A: plotsRelated to the plotsbugDid we break something?p3-nice-to-haveIt should be done this or next sprint

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions