exp show: Include outs in --json output.

This commit is contained in:
David de la Iglesia Castro
2022-01-26 18:45:48 +01:00
parent 1a1e28282d
commit 5e80fcce4f
2 changed files with 56 additions and 2 deletions
+14 -1
View File
@@ -23,6 +23,8 @@ def _collect_experiment_commit(
running=None,
onerror: Optional[Callable] = None,
):
from dvc.dependency import ParamsDependency, RepoDependency
res: Dict[str, Optional[Any]] = defaultdict(dict)
for rev in repo.brancher(revs=[exp_rev]):
if rev == "workspace":
@@ -46,7 +48,17 @@ def _collect_experiment_commit(
"nfiles": dep.meta.nfiles,
}
for dep in repo.index.deps
if type(dep).__name__ != "ParamsDependency" and dep.is_in_repo
if not isinstance(dep, (ParamsDependency, RepoDependency))
}
res["outs"] = {
out.def_path: {
"hash": out.hash_info.value,
"size": out.meta.size,
"nfiles": out.meta.nfiles,
}
for out in repo.index.outs
if not (out.is_metric or out.is_plot)
}
res["queued"] = stash
@@ -121,6 +133,7 @@ def show(
param_deps=False,
onerror: Optional[Callable] = None,
):
if onerror is None:
onerror = onerror_collect
+42 -1
View File
@@ -36,7 +36,6 @@ def make_executor_info(**kwargs):
def test_show_simple(tmp_dir, scm, dvc, exp_stage):
print(dvc.experiments.show()["workspace"])
assert dvc.experiments.show()["workspace"] == {
"baseline": {
"data": {
@@ -48,6 +47,7 @@ def test_show_simple(tmp_dir, scm, dvc, exp_stage):
}
},
"metrics": {"metrics.yaml": {"data": {"foo": 1}}},
"outs": {},
"params": {"params.yaml": {"data": {"foo": 1}}},
"queued": False,
"running": False,
@@ -80,6 +80,7 @@ def test_show_experiment(tmp_dir, scm, dvc, exp_stage, workspace):
}
},
"metrics": {"metrics.yaml": {"data": {"foo": 1}}},
"outs": {},
"params": {"params.yaml": {"data": {"foo": 1}}},
"queued": False,
"running": False,
@@ -343,6 +344,7 @@ def test_show_running_workspace(tmp_dir, scm, dvc, exp_stage, capsys):
},
"metrics": {"metrics.yaml": {"data": {"foo": 1}}},
"params": {"params.yaml": {"data": {"foo": 1}}},
"outs": {},
"queued": False,
"running": True,
"executor": info.location,
@@ -619,3 +621,42 @@ def test_show_parallel_coordinates(tmp_dir, dvc, scm, mocker, capsys):
html_text = (tmp_dir / "dvc_plots" / "index.html").read_text()
assert '"label": "Created"' not in html_text
assert '"label": "foobar"' not in html_text
def test_show_outs(tmp_dir, dvc, scm):
tmp_dir.gen("copy.py", COPY_SCRIPT)
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 && echo out > out",
metrics_no_cache=["metrics.yaml"],
params=["foo", "bar"],
name="copy-file",
deps=["copy.py"],
outs=["out"],
)
scm.add(
[
"dvc.yaml",
"dvc.lock",
"copy.py",
"params.yaml",
"metrics.yaml",
".gitignore",
]
)
scm.commit("init")
outs = dvc.experiments.show()["workspace"]["baseline"]["data"]["outs"]
assert outs == {
"out": {
"hash": ANY,
"size": ANY,
"nfiles": None,
}
}