mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-08 23:09:48 +01:00
@@ -384,7 +384,7 @@ def show_experiments(
|
||||
no_timestamp=False,
|
||||
csv=False,
|
||||
markdown=False,
|
||||
html=False,
|
||||
pcp=False,
|
||||
**kwargs,
|
||||
):
|
||||
from funcy.seqs import flatten as flatten_list
|
||||
@@ -432,7 +432,7 @@ def show_experiments(
|
||||
kwargs.get("iso"),
|
||||
)
|
||||
|
||||
if no_timestamp or html:
|
||||
if no_timestamp or pcp:
|
||||
td.drop("Created")
|
||||
|
||||
for col in ("State", "Executor"):
|
||||
@@ -469,11 +469,11 @@ def show_experiments(
|
||||
}
|
||||
)
|
||||
|
||||
if kwargs.get("only_changed", False) or html:
|
||||
if kwargs.get("only_changed", False) or pcp:
|
||||
td.drop_duplicates("cols", ignore_empty=False)
|
||||
|
||||
html_args = {}
|
||||
if html:
|
||||
pcp_args = {}
|
||||
if pcp:
|
||||
td.dropna("rows", how="all")
|
||||
td.column("Experiment")[:] = [
|
||||
# remove tree characters
|
||||
@@ -481,8 +481,8 @@ def show_experiments(
|
||||
for x in td.column("Experiment")
|
||||
]
|
||||
out = kwargs.get("out") or "dvc_plots"
|
||||
html_args["output_path"] = (Path.cwd() / out).resolve()
|
||||
html_args["color_by"] = kwargs.get("sort_by") or "Experiment"
|
||||
pcp_args["output_path"] = (Path.cwd() / out).resolve()
|
||||
pcp_args["color_by"] = kwargs.get("sort_by") or "Experiment"
|
||||
|
||||
td.render(
|
||||
pager=pager,
|
||||
@@ -492,11 +492,11 @@ def show_experiments(
|
||||
row_styles=row_styles,
|
||||
csv=csv,
|
||||
markdown=markdown,
|
||||
html=html,
|
||||
**html_args,
|
||||
pcp=pcp,
|
||||
**pcp_args,
|
||||
)
|
||||
|
||||
if html and kwargs.get("open"):
|
||||
if pcp and kwargs.get("open"):
|
||||
return ui.open_browser(Path(out) / "index.html")
|
||||
|
||||
|
||||
@@ -556,7 +556,7 @@ class CmdExperimentsShow(CmdBase):
|
||||
csv=self.args.csv,
|
||||
markdown=self.args.markdown,
|
||||
only_changed=self.args.only_changed,
|
||||
html=self.args.html,
|
||||
pcp=self.args.pcp,
|
||||
out=self.args.out,
|
||||
open=self.args.open,
|
||||
)
|
||||
@@ -709,22 +709,24 @@ def add_parser(experiments_subparsers, parent_parser):
|
||||
),
|
||||
)
|
||||
experiments_show_parser.add_argument(
|
||||
"--html",
|
||||
"--parallel-coordinates-plot",
|
||||
"--pcp",
|
||||
dest="pcp",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="Generate a parallel coordinates plot from the tabulated output.",
|
||||
help="Generate a Parallel Coordinates Plot from the tabulated output.",
|
||||
)
|
||||
experiments_show_parser.add_argument(
|
||||
"-o",
|
||||
"--out",
|
||||
default=None,
|
||||
help="Destination folder to save the HTML to",
|
||||
help="Destination folder to save the Parallel Coordinates Plot to",
|
||||
metavar="<path>",
|
||||
).complete = completion.DIR
|
||||
experiments_show_parser.add_argument(
|
||||
"--open",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="Open the HTML directly in the browser.",
|
||||
help="Open the Parallel Coordinates Plot directly in the browser.",
|
||||
)
|
||||
experiments_show_parser.set_defaults(func=CmdExperimentsShow)
|
||||
|
||||
+1
-1
@@ -186,7 +186,7 @@ class TabularData(MutableSequence[Sequence["CellT"]]):
|
||||
if kwargs.pop("csv", False):
|
||||
ui.write(self.to_csv(), end="")
|
||||
|
||||
elif kwargs.pop("html", False):
|
||||
elif kwargs.pop("pcp", False):
|
||||
ui.write(
|
||||
self.to_parallel_coordinates(
|
||||
kwargs["output_path"], kwargs.get("color_by")
|
||||
|
||||
@@ -633,7 +633,7 @@ def test_show_parallel_coordinates(tmp_dir, dvc, scm, mocker):
|
||||
|
||||
dvc.experiments.run(params=["foo=2"])
|
||||
|
||||
assert main(["exp", "show", "--html"]) == 0
|
||||
assert main(["exp", "show", "--pcp"]) == 0
|
||||
kwargs = show_experiments.call_args[1]
|
||||
|
||||
html_text = (tmp_dir / "dvc_plots" / "index.html").read_text()
|
||||
@@ -648,26 +648,24 @@ def test_show_parallel_coordinates(tmp_dir, dvc, scm, mocker):
|
||||
assert '"line": {"color": [2, 1, 0]' in html_text
|
||||
assert '"label": "metrics.yaml:bar"' not in html_text
|
||||
|
||||
assert (
|
||||
main(["exp", "show", "--html", "--sort-by", "metrics.yaml:foo"]) == 0
|
||||
)
|
||||
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, 2.0]' in html_text
|
||||
|
||||
assert main(["exp", "show", "--html", "--out", "experiments"]) == 0
|
||||
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", "--html", "--open"]) == 0
|
||||
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", "--html"]) == 0
|
||||
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
|
||||
|
||||
@@ -761,7 +761,7 @@ def test_experiments_init_type_invalid_choice():
|
||||
parse_args(["exp", "init", "--type=invalid", "cmd"])
|
||||
|
||||
|
||||
def test_show_experiments_html(tmp_dir, mocker):
|
||||
def test_show_experiments_pcp(tmp_dir, mocker):
|
||||
all_experiments = {
|
||||
"workspace": {
|
||||
"baseline": {
|
||||
@@ -783,13 +783,13 @@ def test_show_experiments_html(tmp_dir, mocker):
|
||||
)
|
||||
td = experiments_table.return_value
|
||||
|
||||
show_experiments(all_experiments, html=True)
|
||||
show_experiments(all_experiments, pcp=True)
|
||||
|
||||
td.dropna.assert_called_with("rows", how="all")
|
||||
|
||||
render_kwargs = td.render.call_args[1]
|
||||
|
||||
for arg in ["html", "output_path", "color_by"]:
|
||||
for arg in ["pcp", "output_path", "color_by"]:
|
||||
assert arg in render_kwargs
|
||||
assert render_kwargs["output_path"] == tmp_dir / "dvc_plots"
|
||||
assert render_kwargs["color_by"] == "Experiment"
|
||||
|
||||
@@ -337,7 +337,7 @@ def test_to_parallel_coordinates(tmp_dir, mocker):
|
||||
)
|
||||
renderer = renderer_class.return_value
|
||||
|
||||
td.render(html=True, output_path="foo")
|
||||
td.render(pcp=True, output_path="foo")
|
||||
|
||||
renderer_class.assert_called_with(td, None, td._fill_value)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user