MCPcopy
hub / github.com/treeverse/dvc / metrics_table

Function metrics_table

dvc/compare.py:372–408  ·  view source on GitHub ↗
(
    metrics,
    all_branches: bool = False,
    all_tags: bool = False,
    all_commits: bool = False,
    precision: Optional[int] = None,
    round_digits: bool = False,
)

Source from the content-addressed store, hash-verified

370
371
372def metrics_table(
373 metrics,
374 all_branches: bool = False,
375 all_tags: bool = False,
376 all_commits: bool = False,
377 precision: Optional[int] = None,
378 round_digits: bool = False,
379):
380 from dvc.utils.diff import format_dict
381 from dvc.utils.flatten import flatten
382
383 td = TabularData(["Revision", "Path"], fill_value="-")
384
385 for branch, val in metrics.items():
386 for fname, metric in val.get("data", {}).items():
387 row_data: dict[str, str] = {"Revision": branch, "Path": fname}
388 metric = metric.get("data", {})
389 flattened = (
390 flatten(format_dict(metric))
391 if isinstance(metric, dict)
392 else {"": metric}
393 )
394 row_data.update(
395 {
396 k: _format_field(v, precision, round_digits)
397 for k, v in flattened.items()
398 }
399 )
400 td.row_from_dict(row_data)
401
402 rev, path, *metrics_headers = td.keys()
403 td.project(rev, path, *sorted(metrics_headers))
404
405 if not any([all_branches, all_tags, all_commits]):
406 td.drop("Revision")
407
408 return td
409
410
411def show_metrics(

Calls 11

row_from_dictMethod · 0.95
keysMethod · 0.95
projectMethod · 0.95
dropMethod · 0.95
flattenFunction · 0.90
format_dictFunction · 0.90
TabularDataClass · 0.85
_format_fieldFunction · 0.85
itemsMethod · 0.80
getMethod · 0.45
updateMethod · 0.45