mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
add integration test for dvclive 2.x->3.x plots
This commit is contained in:
committed by
Dave Berenbaum
parent
f9340ed7b9
commit
0e66aa2b6a
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user