diff --git a/src/dvclive/plots/custom.py b/src/dvclive/plots/custom.py index 0ea1527..2d7ecd3 100644 --- a/src/dvclive/plots/custom.py +++ b/src/dvclive/plots/custom.py @@ -23,6 +23,9 @@ def __init__( ) -> None: super().__init__(name, output_folder) self.name = self.name.replace(".json", "") + if not template: + template = None + config = { "template": template, "x": x, diff --git a/tests/plots/test_custom.py b/tests/plots/test_custom.py index 349c726..c87d662 100644 --- a/tests/plots/test_custom.py +++ b/tests/plots/test_custom.py @@ -56,3 +56,30 @@ def test_log_custom_plot_multi_y(tmp_dir): "x_label": "x_label", "y_label": "y_label", } + + +def test_log_custom_plot_with_template_as_empty_string(tmp_dir): + live = Live() + out = tmp_dir / live.plots_dir / CustomPlot.subfolder + + datapoints = [{"x": 1, "y": 2}, {"x": 3, "y": 4}] + live.log_plot( + "custom_linear", + datapoints, + x="x", + y="y", + template="", + title="custom_title", + x_label="x_label", + y_label="y_label", + ) + + assert json.loads((out / "custom_linear.json").read_text()) == datapoints + # 'template' should not be in plot_config. Default template will be assigned later. + assert live._plots["custom_linear"].plot_config == { + "title": "custom_title", + "x": "x", + "y": "y", + "x_label": "x_label", + "y_label": "y_label", + }