Skip to content

iterative/dvc-render

Repository files navigation

dvc-render

PyPI Status Python Version License

Tests Codecov pre-commit Black

dvc-render is a library for rendering data stored in DVC plots format into different output formats, like Vega. It can also generate HTML and MarkDown reports containing multiple plots.

It is used internally by DVC, DVCLive, and Studio.

Features

  • Renderers

Take data stored in DVC plots format alongside plot properties in order to render a plot in different formats.

  • Reports

Take multiple renderers and build an HTML or MarkDown report.

  • Templates

Support for rendering Vega plots using custom of pre-defined templates.

Requirements

The basic usage of rendering Vega Plots doesn't have any dependencies outside Python>=3.8.

Additional features are specified as optional requirements:

dvc-render/setup.cfg

Lines 27 to 32 in 49b8f8a

[options.extras_require]
table =
tabulate>=0.8.7
markdown =
%(table)s
matplotlib

Installation

You can install DVC render via pip from PyPI:

$ pip install dvc-render

Usage

  • Renderer & Templates
from dvc_render import VegaRenderer
properties = {"template": "confusion", "x": "predicted", "y": "actual"}
 datapoints = [
     {"predicted": "B", "actual": "A"},
     {"predicted": "A", "actual": "A"},
 ]

renderer = VegaRenderer(datapoints, "foo", **properties)
plot_content = renderer.get_filled_template()

plot_content contains a valid Vega plot using the confusion matrix template.

  • Report
from dvc_render import render_html
render_html([renderer], "report.html")

Contributing

Contributions are very welcome. To learn more, see the Contributor Guide.

License

Distributed under the terms of the Apache 2.0 license, DVC render is free and open source software.

Issues

If you encounter any problems, please file an issue along with a detailed description.