diff --git a/tests/integration/plots/conftest.py b/tests/integration/plots/conftest.py index 1e6f36ea7..13e91a87c 100644 --- a/tests/integration/plots/conftest.py +++ b/tests/integration/plots/conftest.py @@ -191,3 +191,58 @@ def repo_with_config_plots(tmp_dir, scm, dvc, run_copy_metrics): } return make + + +@pytest.fixture +def repo_with_dvclive_plots(tmp_dir, scm, dvc, run_copy_metrics): + def make(): + metrics = [ + {"step": 1, "metric": 0.1}, + {"step": 2, "metric": 0.2}, + {"step": 3, "metric": 0.3}, + ] + + metrics_path = tmp_dir / "dvclive" / "plots" / "metrics" / "metric.tsv" + metrics_path.parent.mkdir(parents=True) + metrics_path.dump_json(metrics) + + plots_config_v1 = [ + { + "plots/metrics": { + "x": "step", + } + } + ] + + from dvc.utils.serialize import modify_yaml + + dvcyaml_path_v1 = tmp_dir / "dvclive" / "dvc.yaml" + with modify_yaml(dvcyaml_path_v1) as dvcfile_content: + dvcfile_content["plots"] = plots_config_v1 + scm.add([metrics_path, dvcyaml_path_v1]) + scm.commit("add dvclive 2.x plots") + + yield { + "data": {metrics_path: metrics}, + "configs": {dvcyaml_path_v1: plots_config_v1}, + } + + plots_config_v2 = [ + { + "dvclive/plots/metrics": { + "x": "step", + } + } + ] + + dvcyaml_path_v1.unlink() + dvcyaml_path_v2 = tmp_dir / "dvc.yaml" + with modify_yaml(dvcyaml_path_v2) as dvcfile_content: + dvcfile_content["plots"] = plots_config_v2 + + yield { + "data": {metrics_path: metrics}, + "configs": {dvcyaml_path_v2: plots_config_v2}, + } + + return make diff --git a/tests/integration/plots/test_plots.py b/tests/integration/plots/test_plots.py index fe62f16d8..8a22918b9 100644 --- a/tests/integration/plots/test_plots.py +++ b/tests/integration/plots/test_plots.py @@ -458,3 +458,18 @@ def test_repo_with_config_plots(tmp_dir, capsys, repo_with_config_plots): assert html_result["linear_train_vs_test"]["data"]["values"] == ble # TODO check json results once vscode is able to handle flexible plots + + +@pytest.mark.vscode +def test_repo_with_dvclive_plots(tmp_dir, capsys, repo_with_dvclive_plots): + next(repo_with_dvclive_plots()) + + for s in ("show", "diff"): + _, json_result, split_json_result = call(capsys, subcommand=s) + expected_result = { + "data": { + "dvclive/plots/metrics/metric.tsv": [], + }, + } + assert json_result == expected_result + assert split_json_result == expected_result