Skip to content

plots: improve vs code/studio integration #9018

@dberenbaum

Description

@dberenbaum

This is an issue to track potential plots changes to streamline some of the plots handling happening in VS Code and Studio. It should enable VS Code and Studio to drop custom rendering for things like setting strokeDash for filename and field, and it should enable them to take advantage of DVC plots improvements like those in #8900.

The rest of this issue is copied from treeverse/vscode-dvc#3130 (comment)_


There's a rough POC of the ideas above in https://github.com/iterative/dvc/tree/plots-fields and https://github.com/iterative/dvc-render/tree/plots-fields.

These changes updates output to include these new fields:

```json
"dvc_id": "workspace::train/acc.tsv::train/acc",
"dvc_rev": "workspace",
"dvc_filename": "train/acc.tsv",
"dvc_field": "train/acc",
"dvc_source": "train/acc.tsv::train/acc"
```
  • Incorporates these into templates, using dvc_rev for color and dvc_source for strokeDash.
  • Drops data_version_info.

Here's an example of dvc plots diff --split --json output:

{
  "dvc.yaml::Accuracy": [
    {
      "type": "vega",
      "revisions": [
        "HEAD",
        "workspace"
      ],
      "content": {
        "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
        "data": {
          "values": "<DVC_METRIC_DATA>"
        },
        "title": "dvc.yaml::Accuracy",
        "width": 300,
        "height": 300,
        "params": [
          {
            "name": "smooth",
            "value": 0.001,
            "bind": {
              "input": "range",
              "min": 0.001,
              "max": 1,
              "step": 0.001
            }
          }
        ],
        "layer": [
          {
            "mark": "line",
            "encoding": {
              "x": {
                "field": "step",
                "type": "quantitative",
                "title": "step"
              },
              "y": {
                "field": "dvc_inferred_y_value",
                "type": "quantitative",
                "title": "accuracy",
                "scale": {
                  "zero": false
                }
              },
              "color": {
                "field": "dvc_rev",
                "type": "nominal"
              },
              "strokeDash": {
                "field": "dvc_source",
                "type": "nominal"
              }
            },
            "transform": [
              {
                "loess": "dvc_inferred_y_value",
                "on": "step",
                "groupby": [
                  "dvc_rev",
                  "dvc_source"
                ],
                "bandwidth": {
                  "signal": "smooth"
                }
              }
            ]
          },
          {
            "mark": {
              "type": "point",
              "tooltip": {
                "content": "data"
              }
            },
            "encoding": {
              "x": {
                "field": "step",
                "type": "quantitative",
                "title": "step"
              },
              "y": {
                "field": "dvc_inferred_y_value",
                "type": "quantitative",
                "title": "accuracy",
                "scale": {
                  "zero": false
                }
              },
              "color": {
                "field": "dvc_rev",
                "type": "nominal"
              },
              "strokeDash": {
                "field": "dvc_source",
                "type": "nominal"
              }
            }
          }
        ]
      },
      "datapoints": {
        "workspace": [
          {
            "step": "0",
            "train/acc": "0.5262",
            "dvc_inferred_y_value": "0.5262",
            "rev": "workspace::train/acc.tsv::train/acc",
            "dvc_id": "workspace::train/acc.tsv::train/acc",
            "dvc_rev": "workspace",
            "dvc_filename": "train/acc.tsv",
            "dvc_field": "train/acc",
            "dvc_source": "train/acc.tsv::train/acc"
          },
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    A: plotsRelated to the plotsdiscussionrequires active participation to reach a conclusion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions