-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fill anchors instead of quoted anchors #28
Comments
@pared Thoughts on this? |
The use case makes perfect sense. However, there is a certain reason why we quote the anchors, and this is because we treat the templates as dictionaries (not only in code, but for example in integrations, like vscode). Having quoted anchors allows us to parse and dump from/to json. We could think about involving some logic regarding the quotes. In the case provided by @WilliamHarvey97 we could detect that anchors are used within a string and it's safe to replace them without quotes. |
@pared Maybe we aren't being clear about whether templates are:
Is VS Code expecting each anchor to be injected as a value to a JSON key or as a string into a text doc? cc @mattseddon |
@dberenbaum the main problem is that templates are both. When replacing the anchors we treat them as text files. Inside DVC and the integrations we treat them as JSON dictionaries, for convenient parsing. Also, as I recall we might be relying on the current behavior in some places (@mattseddon don't you change the colors of the plots somewhere?). |
@dberenbaum we are currently holding the template as a string so that we can do a
@pared we update the
Where I am open to this changing we just need to be careful not to break anything. Note: the way that our code is currently setup could be improved as we actually convert the initial CLI output into a JSON object and then back to a string, and then back to JSON once we know which datapoints we want to display. |
So I guess we have two ways to go:
There still exists possibility to treat templates only as dictionaries. In this way, we would remove anchors and would need to provide |
Related #23 ? |
@pared Could you explain more or show an example of what templates would look like without anchors? Also, it might be fine to not allow use cases like One more thought: it seems like only |
That would make sense. Regarding the no-anchors approach: The issue gets a bit complicated when talking about different types of plots. For example, in our simplest plot, we can provide configuration for |
BTW @WilliamHarvey97 what kind of plot are you trying to implement? Maybe we could approach it in some other way. |
I was implementing an actual v.s. predicted plot. I wanted to add MAPE, RMSE, R2 and other useful metrics to show at the top of the plot. We often share our results within my team and I found it useful to include these metrics at the top so we don't need to dig further. In the end, we chose to version png image. We wanted to use the color of each point to encode something else and in the current implementation of dvc-render, the color is reserved for version encoding. I prefer the side-to-side comparison of png. |
@WilliamHarvey97 Got it. Well, what you are trying to achieve should be the scope of iterative/dvc#7086. Would you mind sharing some example of your use case? I am preparing some backward incompatible changes for dvc 3.0 and knowing more use cases might help me define it better. |
This would be a really nice feature to support since a lot of use cases depends on the calculate transform. In my case I wanted to normalize across all the elements in each revision. I ended up doing a "hack" and using the
Here is a working example in vega-lite:
|
@daniel-falk |
In my custom vega-lite template, I tried do to something like this to compute the sum of squared residuals:
However, it seems impossible to do this because it looks like dvc-render replace only a quoted anchor like
f'"{cls.anchor(name)}"'
instead of just the anchorf'{cls.anchor(name)}'
dvc-render/src/dvc_render/vega_templates.py
Line 78 in 422bfe6
I didn't dig a lot into this, but I was just wondering if this could just be this way so we could use anchors on datum?
Thank you!
The text was updated successfully, but these errors were encountered: