Skip to content

Commit

Permalink
Merge pull request iterative#3202 from efiop/flatten
Browse files Browse the repository at this point in the history
dvc: replace flatten_dict with flatten_json
  • Loading branch information
efiop authored Jan 20, 2020
2 parents 81029f8 + 1eb82ac commit 503401d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
13 changes: 3 additions & 10 deletions dvc/repo/metrics/diff.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
from collections import defaultdict

from flatten_dict import flatten
from flatten_json import flatten

from dvc.exceptions import NoMetricsError

Expand Down Expand Up @@ -34,25 +34,18 @@ def _diff_vals(old, new):
return res


# dot_reducer is not released yet (flatten-dict > 0.2.0)
def _dot(k1, k2):
if k1 is None:
return k2
return "{0}.{1}".format(k1, k2)


def _diff_dicts(old_dict, new_dict):
old_default = None
new_default = None

if isinstance(new_dict, dict):
new = flatten(new_dict, reducer=_dot)
new = flatten(new_dict, ".")
else:
new = defaultdict(lambda: "not a dict")
new_default = "unable to parse"

if isinstance(old_dict, dict):
old = flatten(old_dict, reducer=_dot)
old = flatten(old_dict, ".")
else:
old = defaultdict(lambda: "not a dict")
old_default = "unable to parse"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def run(self):
"networkx>=2.1,<2.4",
"speedcopy>=2.0.1",
"pyfastcopy>=1.0.3",
"flatten-dict>=0.2.0",
"flatten_json>=0.1.6",
"texttable>=0.5.2",
]

Expand Down

0 comments on commit 503401d

Please sign in to comment.