cmd: implement '--show-md' flag for 'dvc metrics show' (#4770) (#5161)

This commit is contained in:
Pavel Ditenbir
2020-12-30 02:17:41 +02:00
committed by GitHub
parent 6fcafc9121
commit 23811e028c
2 changed files with 49 additions and 1 deletions
+40
View File
@@ -19,6 +19,7 @@ def test_metrics_diff(dvc, mocker):
"-R",
"--all",
"--show-json",
"--show-md",
"--targets",
"target1",
"target2",
@@ -330,3 +331,42 @@ def test_metrics_show_precision():
Revision Path a b.ad b.bc
branch_1 metrics.json 1.0987654 1.5342673 2.9877255"""
)
def test_metrics_show_default():
assert _show_metrics(
{
"metrics.yaml": {
"x.b": {"old": 5, "new": 6},
"a.d.e": {"old": 3, "new": 4, "diff": 1},
"a.b.c": {"old": 1, "new": 2, "diff": 1},
}
},
) == textwrap.dedent(
"""\
Path diff new old
x.b — 6 5
a.d.e 1 4 3
a.b.c 1 2 1"""
)
def test_metrics_show_md():
assert _show_metrics(
{
"metrics.yaml": {
"x.b": {"old": 5, "new": 6},
"a.d.e": {"old": 3, "new": 4, "diff": 1},
"a.b.c": {"old": 1, "new": 2, "diff": 1},
}
},
markdown=True,
) == textwrap.dedent(
"""\
| Path | diff | new | old |
|--------|--------|-------|-------|
| x.b | — | 6 | 5 |
| a.d.e | 1 | 4 | 3 |
| a.b.c | 1 | 2 | 1 |
"""
)