mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-28 07:18:29 +01:00
metrics: rework metrics implementation (#3658)
Dropping support for all types except json and yaml. No more xpath support. Fixes #3572
This commit is contained in:
+16
-3
@@ -1,8 +1,6 @@
|
||||
import json
|
||||
from collections import defaultdict
|
||||
|
||||
from flatten_json import flatten
|
||||
|
||||
|
||||
def _parse(raw):
|
||||
if raw is None or isinstance(raw, (dict, list, int, float)):
|
||||
@@ -37,7 +35,9 @@ def _flatten(d):
|
||||
return defaultdict(lambda: None)
|
||||
|
||||
if isinstance(d, dict):
|
||||
return defaultdict(lambda: None, flatten(d, "."))
|
||||
from flatten_json import flatten as fltn
|
||||
|
||||
return defaultdict(lambda: None, fltn(d, "."))
|
||||
|
||||
return defaultdict(lambda: "unable to parse")
|
||||
|
||||
@@ -103,3 +103,16 @@ def table(header, rows):
|
||||
t.add_rows([header] + rows)
|
||||
|
||||
return t.draw()
|
||||
|
||||
|
||||
def format_dict(d):
|
||||
ret = {}
|
||||
for key, val in d.items():
|
||||
if isinstance(val, dict):
|
||||
new_val = format_dict(val)
|
||||
elif isinstance(val, list):
|
||||
new_val = str(val)
|
||||
else:
|
||||
new_val = val
|
||||
ret[key] = new_val
|
||||
return ret
|
||||
|
||||
Reference in New Issue
Block a user