Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions dvc/command/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def run(self):
rel: str = self.args.out or "plots.html"
path = (Path.cwd() / rel).resolve()
self.repo.plots.write_html(
path, plots=plots, html_template_path=self.args.html_template
path, plots=plots, html_template_path=self.args.html
)

except DvcException:
Expand Down Expand Up @@ -249,8 +249,8 @@ def _add_output_arguments(parser):
help="Open plot file directly in the browser.",
)
parser.add_argument(
"--html-template",
"--html",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is backwards incompatible, right? Can we keep an alias or something?

default=None,
help="Custom HTML template for VEGA visualization.",
help="Custom HTML for VEGA visualization.",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
help="Custom HTML for VEGA visualization.",
help="File with custom HTML container for DVC plots.",

metavar="<path>",
)
2 changes: 1 addition & 1 deletion dvc/config_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,5 +225,5 @@ class RelPath(str):
# enabled by default. It's of no use, kept for backward compatibility.
Optional("parametrization", default=True): Bool
},
"plots": {"html_template": str},
"plots": {"html": str},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it compatible with the old schema? Some users might have an old version in their workspace.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is true, but the feature is relatively new and I think there is more harm in leaving html_template because users might associate template with vega templates and not understand what it actually is.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we adopt the old version, and transfer it to new ones? Or at least give some friendly messages when it happens.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feature was only introduced in the last minor version or so, and it was specifically developed for the Studio team, so I wouldn't expect many (probably any) other people are using it. Feel free to support both or whatever you think is best, but I don't think this is a breaking change worth worrying about.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK @mnrozhkov is the person that needs to know about this change, also one user on discord. I will try to reach out to this user.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Studio guys will complain about problems with this, we should not break an already released schema. We have to keep older name, but we could introduce an alias.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My mistake, I didn't think it would be a big deal for studio.

Copy link
Copy Markdown
Contributor

@jorgeorpinel jorgeorpinel Jul 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related feedback, for the record: #5694 (review) (for the alias)

}
2 changes: 1 addition & 1 deletion dvc/repo/plots/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def write_html(
):
if not html_template_path:
html_template_path = self.repo.config.get("plots", {}).get(
"html_template", None
"html", None
)
if html_template_path and not os.path.isabs(html_template_path):
html_template_path = os.path.join(
Expand Down
4 changes: 2 additions & 2 deletions dvc/utils/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<script src="https://cdn.jsdelivr.net/npm/vega-embed@6.5.1"></script>
</head>
<body>
{plot_divs}
{dvc_plots}
</body>
</html>"""

Expand All @@ -29,7 +29,7 @@ def __init__(self, placeholder):


class HTML:
PLACEHOLDER = "plot_divs"
PLACEHOLDER = "dvc_plots"
PLACEHOLDER_FORMAT_STR = f"{{{PLACEHOLDER}}}"

def __init__(self, template: str = None):
Expand Down
6 changes: 3 additions & 3 deletions tests/func/utils/test_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@
<script type="text/javascript" src="vega-embed"></script>
</head>
<body>
{plot_divs}
{dvc_plots}
</body>
</html>"""


@pytest.mark.parametrize(
"template,page_elements,expected_page",
[
(None, ["content"], PAGE_HTML.format(plot_divs="content")),
(None, ["content"], PAGE_HTML.format(dvc_plots="content")),
(
CUSTOM_PAGE_HTML,
["content"],
CUSTOM_PAGE_HTML.format(plot_divs="content"),
CUSTOM_PAGE_HTML.format(dvc_plots="content"),
),
],
)
Expand Down