Dvc: plots: require templates to be JSON and treat them as such

Created on 15 Jun 2020  路  3Comments  路  Source: iterative/dvc

In our current code, we assume that the template might be in any string format and so we substitute the anchors as strings. We should really start requiring the templates to be JSON, so we could treat them as dicts internally and have a better control over the special vega options. E.g. smoothing from https://github.com/iterative/dvc/issues/3906 , could be handled not with a separate template but a special plot property (https://github.com/iterative/dvc/issues/3906#issuecomment-639483890).

  • [ ] Require templates to be in JSON format
  • [ ] handle template contents (Template.content currently might be str or dict) as dicts
  • [ ] add plot smoothing option (might be extracted into as separate issue later, depending on complexity)
enhancement p2-medium refactoring

Most helpful comment

The initial requirement was related to HTML template support. This is where the strings come from. Later --show-vega requirements become a higher priority.

So, we can easily refuse the HTML\string requirement and move to full JSON. But this might require some minor template redesign.

All 3 comments

The initial requirement was related to HTML template support. This is where the strings come from. Later --show-vega requirements become a higher priority.

So, we can easily refuse the HTML\string requirement and move to full JSON. But this might require some minor template redesign.

TODO:

  • [ ] Remove anchors from Template class
  • [ ] Replace mechanism of filling anchor from Template._fill_metadata to one working with dict's. funcy.merge might come in hand
  • [ ] map existing options and anchors to proper JSON path according to vega-lite schema.

@dmpetrov noted a good point:
Some of the anchor's paths might not be constant.
Example:
setting title on axis x:
in our default template
encoding/x/title

and for linear sample for vega (not vega-lite) is different:
axes/{scale-corresponding-to-x}/title

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dnabanita7 picture dnabanita7  路  3Comments

ghost picture ghost  路  3Comments

tc-ying picture tc-ying  路  3Comments

shcheklein picture shcheklein  路  3Comments

prihoda picture prihoda  路  3Comments