exp show: Drop --pcp. (#9270)

Closes #9268
This commit is contained in:
David de la Iglesia Castro
2023-05-19 15:36:33 +05:45
committed by GitHub
parent cdba65f27e
commit 02f7fcae73
4 changed files with 11 additions and 182 deletions
-79
View File
@@ -551,85 +551,6 @@ def test_show_only_changed(tmp_dir, dvc, scm, capsys, copy_script):
assert "metrics.yaml:goobar" in cap.out
def test_show_parallel_coordinates(tmp_dir, dvc, scm, mocker, capsys, copy_script):
from dvc.commands.experiments import show
webbroser_open = mocker.patch("webbrowser.open")
show_experiments = mocker.spy(show, "show_experiments")
params_file = tmp_dir / "params.yaml"
params_data = {
"foo": 1,
"bar": 1,
}
(tmp_dir / params_file).dump(params_data)
dvc.run(
cmd="python copy.py params.yaml metrics.yaml",
metrics_no_cache=["metrics.yaml"],
params=["foo", "bar"],
name="copy-file",
deps=["copy.py"],
)
scm.add(
[
"dvc.yaml",
"dvc.lock",
"copy.py",
"params.yaml",
"metrics.yaml",
".gitignore",
]
)
scm.commit("init")
dvc.experiments.run(params=["foo=2"])
assert main(["exp", "show", "--pcp"]) == 0
kwargs = show_experiments.call_args[1]
html_text = (tmp_dir / "dvc_plots" / "index.html").read_text()
assert all(rev in html_text for rev in ["workspace", "master"])
assert "[exp-" not in html_text
assert '{"label": "metrics.yaml:foo", "values": [2.0, 1.0]}' in html_text
assert '{"label": "params.yaml:foo", "values": [2.0, 1.0]}' in html_text
assert '"line": {"color": [1, 0]' in html_text
assert '"label": "metrics.yaml:bar"' not in html_text
assert '"label": "Created"' not in html_text
assert main(["exp", "show", "--pcp", "--sort-by", "metrics.yaml:foo"]) == 0
kwargs = show_experiments.call_args[1]
html_text = (tmp_dir / "dvc_plots" / "index.html").read_text()
assert '"line": {"color": [2.0, 1.0]' in html_text
assert main(["exp", "show", "--pcp", "--out", "experiments"]) == 0
kwargs = show_experiments.call_args[1]
assert kwargs["out"] == "experiments"
assert (tmp_dir / "experiments" / "index.html").exists()
assert main(["exp", "show", "--pcp", "--open"]) == 0
webbroser_open.assert_called()
params_data = {"foo": 1, "bar": 1, "foobar": 2}
(tmp_dir / params_file).dump(params_data)
assert main(["exp", "show", "--pcp"]) == 0
html_text = (tmp_dir / "dvc_plots" / "index.html").read_text()
assert '{"label": "foobar", "values": [2.0, null, null]}' in html_text
assert main(["exp", "show", "--pcp", "--drop", "foobar"]) == 0
html_text = (tmp_dir / "dvc_plots" / "index.html").read_text()
assert '"label": "Created"' not in html_text
assert '"label": "foobar"' not in html_text
assert main(["exp", "show", "--pcp", "--drop", "Experiment"]) == 0
html_text = (tmp_dir / "dvc_plots" / "index.html").read_text()
assert '"label": "Experiment"' not in html_text
@pytest.mark.vscode
def test_show_outs(tmp_dir, dvc, scm, erepo_dir, copy_script):
params_file = tmp_dir / "params.yaml"
-18
View File
@@ -374,21 +374,3 @@ def test_drop_duplicates_invalid_axis():
with pytest.raises(ValueError, match="Invalid 'axis' value foo."):
td.drop_duplicates("foo")
def test_to_parallel_coordinates(tmp_dir, mocker):
(tmp_dir / "foo").mkdir()
td = TabularData(["categorical", "scalar"])
td.extend([["foo", "0.1"], ["bar", "2"]])
write = mocker.patch("dvc_render.html.render_html")
renderer_class = mocker.patch("dvc_render.plotly.ParallelCoordinatesRenderer")
renderer = renderer_class.return_value
td.to_parallel_coordinates(output_path="foo")
renderer_class.assert_called_with(
td.as_dict(), color_by=None, fill_value=td._fill_value
)
write.assert_called_with(renderers=[renderer], output_file="foo")