plots: document html template#2472
Conversation
This comment has been minimized.
This comment has been minimized.
jorgeorpinel
left a comment
There was a problem hiding this comment.
Fixing broken links (will commit, please git pull)
This comment has been minimized.
This comment has been minimized.
|
I have edited the guide heavily and had minor edits in ref documents. Guide's title and filename are also changed. Please pull :) Sidebar doesn't have a link for the document. |
This comment has been minimized.
This comment has been minimized.
iesahin
left a comment
There was a problem hiding this comment.
The web server part seems a bit irrelevant, as it seems possible to link the JS files directly to the template. Browsers should be loading the src of <script> tags from local files if I'm not mistaken. The current guide leads the user to run the web server for their own local plots always.
I would like the web server part removed and template to have <script src="my-vega.js"/> elements instead.
|
|
||
| DVC allows to provide a custom HTML template to avoid this requirement. | ||
|
|
||
| ## Example: Setup local server with Vega libraries |
There was a problem hiding this comment.
Is it not possible to skip the web server part and embed the JavaScript files directly in the template with something like <script src="./vega.js"/>? @pared
There was a problem hiding this comment.
This was my initial idea, but I like the server version more due to its robustness:
If we specify server, we are pretty sure the address won't change for the same network. In case of local path, we need to assure two things:
- that template path is absolute path (
dvc plotsproduces html's in cwd, so relative paths would require some special logic dedicated to resolving vega libs paths according tocwd) - that all users copying given repo will have the vega libs under the same path
Using local server, I intend to point user to a solution that would be viable for intranet and would work without every user having to put libs in same place, or modify the project each time they change the machine they work on.
There was a problem hiding this comment.
The final plots document will always need the webserver running in this case, right?
For the intranets, I see your points. That's surely more robust but that configuration can be completely different, e.g., they may already have a central URL to put the files and we don't expect users to copy-paste this template to their workflow.
We just want to show how to supply a template and the user might be looking for a way to render their plots completely differently.
I don't have a strong opinion on this and will trust your judgment. If you see it's better this way, let's keep it. For me, although it has some extra parts, the guide satisfies the purpose of describing the templates. Thank you.
There was a problem hiding this comment.
I agree that server approach is overkill for example purposes, and tries to direct user into "proper" direction. Maybe lets make an example for local path, and just add note on the bottom of the page why one should consider "static" URL to js?
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Hey, I managed to modify the guide to use local files.
There was a problem hiding this comment.
@iesahin I'm still seeing the web server section so not sure what the conclusion was here.
88b56ce to
9fdb8e3
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
9fdb8e3 to
198aace
Compare
There was a problem hiding this comment.
OK I finally took a good look at this and there's lots of info here, which is great. Thanks for all the effort so far @pared and @iesahin ! Here's my high-level review:
TBH if the change is basically to address treeverse/dvc#5679 specifically (see #2402 (comment)), I think the changes are a bit too much. Instead of a whole guide we can probably do with a section or example in the params cmd ref index (https://dvc.org/doc/command-reference/plots). It needs updating anyway since it only mentions Vega templates now.
In summary, I think we should summarize the current guide (quite a bit) and put in the plots index instead, probably both as updates to the Templating sections and as an example.
Also @iesahin I think we have enough info, mind taking this over? 🙏
But @pared def try to keep in mind its better to merge than rebase in docs PRs to avoid force pushing stuff we commit directly from Git (e.g. typos -- we do this often). Thanks!
Co-authored-by: Restyled.io <commits@restyled.io>
There was a problem hiding this comment.
Getting there!
Also, should we wait for a decision on treeverse/dvc#5694 (review)? Cc @pared. Otherwise we should remove the awaiting-dvc-merge label.
Thanks.
| ## HTML templates | ||
|
|
||
| By default, the plots generated by `dvc plots` require Internet access to load | ||
| Vega JavaScript libraries. It's possible to supply a custom HTML file to the | ||
| `--html-template` option of `dvc plot show` and `dvc plot diff` when the | ||
| Internet access is not available. |
There was a problem hiding this comment.
I don't think we should present this as a solution for offline envs initially. E,g. you can also use this feature even when you're online. Let's move most of that motivation to the example instead please.
There was a problem hiding this comment.
So what's a more general motivation for this section that explains the feature? Perhaps something like "The default plots use a plain HTML file which uses cloud Vega libraries." Plus maybe link to the official "Vega libs" location. Is it https://github.com/vega/vega/releases?
There was a problem hiding this comment.
Another motivation may be to put some extra stuff to the plots, like a banner, title etc. But in general, I think people will understand if something works offline, it can also work online.
There was a problem hiding this comment.
Yes but offline vs online is not the broadest use, right? Templates are about customization in general. Offline js imports just happens to be one thing you can customize.
| > `--html-template` provides a custom HTML file to inject plots generated by | ||
| > DVC. | ||
|
|
||
| You can create an HTML file with `<script>` references to local Vega libraries. |
There was a problem hiding this comment.
Same. That's not the sole use of this feature.
There was a problem hiding this comment.
Main motivation is generating plots without Internet access and (maybe) customizing them. References to local Vega libraries captures both. Without Vega, the user cannot produce plots.
There was a problem hiding this comment.
I realize that was the original purpose of the PR but once implemented, it's just one application of HTML template customization, I think.
| ### Example for the HTML template | ||
|
|
||
| Download the Vega libraries into the directory where you'll produce the |
There was a problem hiding this comment.
Should the title be more specific? Something about offline environments or without Internet access.
There was a problem hiding this comment.
(And let's start with a quick motivation intro as mentioned earlier 🙂)
|
@jorgeorpinel I think the decision is there: |
jorgeorpinel
left a comment
There was a problem hiding this comment.
Specific suggestions on HTML template example file.
jorgeorpinel
left a comment
There was a problem hiding this comment.
Copy edits to HTML templates (will commit)
Co-authored-by: Restyled.io <commits@restyled.io>
jorgeorpinel
left a comment
There was a problem hiding this comment.
Example copy edits (committing)
Co-authored-by: Restyled.io <commits@restyled.io>
There was a problem hiding this comment.
Last questions @iesahin please finalize and lmk for merge (feel free to merge if you can) 👍
| There may be times when you need to produce plots without Internet access, or | ||
| want to customize the plots output to put some extra content, like banners or | ||
| extra text. DVC allows to replace the HTML file that contains the final plots. |
There was a problem hiding this comment.
| There may be times when you need to produce plots without Internet access, or | |
| want to customize the plots output to put some extra content, like banners or | |
| extra text. DVC allows to replace the HTML file that contains the final plots. | |
| There may be times when you need to produce plots without Internet access. | |
| DVC allows to replace the HTML file that contains the final plots. |
or want to customize the plots output to put some extra content, like banners or extra text
The example isn't about that. Maybe mention these other examples in the Description subsection? Will leave suggestion ⏳
There was a problem hiding this comment.
I don't think we can enumerate all use cases of templates in the description? We implement one of the example ideas, the rest can be done in a similar way.
There was a problem hiding this comment.
I wasn't suggesting to enumerate every single possible case. My point was that this "Offline HTML Template" example is not about extra HTML content so that sentence just seems unrelated. Could just be removed IMO
| using the the `--html-template` option. This allows you to customize the | ||
| container where DVC will inject plots it generates. |
There was a problem hiding this comment.
⌛ Extracted from the example:
| using the the `--html-template` option. This allows you to customize the | |
| container where DVC will inject plots it generates. | |
| using the the `--html-template` option. This allows you to customize the | |
| container where DVC will inject the plots it generates. | |
| For example, you can add extra content to the web page, like banners or links. |
|
Merging this to move forward :) |
❗ Please read the guidelines in the Contributing to the Documentation list if you make any substantial changes to the documentation or JS engine.
🐛 Please make sure to mention
Fix #issue(if applicable) in the description of the PR. This causes GitHub to close it automatically when the PR is merged.Please choose to allow us to edit your branch when creating the PR.
Thank you for the contribution - we'll try to review it as soon as possible. 🙏
Fixes #2402
Closes #1175