Skip to content

Commit fd80c6e

Browse files
committed
fix: handle enum data type in parameters-difference (fixes #143)
Backported from master. Adds support for enum type in build_value() so that `experimaestro parameters-difference` works with enum parameters.
1 parent d9e0509 commit fd80c6e

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/experimaestro/tools/diff.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import importlib
12
from itertools import chain
23
from typing import Dict, Any
34
from pathlib import Path
45
import json
6+
from experimaestro.core.objects.config_utils import getqualattr
57
from termcolor import colored
68

79

@@ -42,6 +44,11 @@ def build_value(data, store: Store):
4244
elif t == "path.serialized":
4345
# Again, do not return anything (won't change the identifier)
4446
return None
47+
elif t == "enum":
48+
module = importlib.import_module(data["module"])
49+
enumClass = getqualattr(module, data["enum"])
50+
return enumClass[data["value"]]
51+
4552
elif t is None:
4653
return {key: build_value(value, store) for key, value in data.items()}
4754
assert False, f"Data type {t} not handled"
@@ -71,7 +78,7 @@ def load(path: Path):
7178

7279

7380
def print_diff(path: str, conf1: Any, conf2: Any):
74-
if type(conf1) != type(conf2):
81+
if type(conf1) is not type(conf2):
7582
print(f"[{colored(path, 'red')}] {conf1} and {conf2} of different types")
7683

7784
if isinstance(conf1, ObjectProxy) and isinstance(conf2, ObjectProxy):

0 commit comments

Comments
 (0)