summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2021-03-04 13:57:43 +0100
committerDaniel Friesel <daniel.friesel@uos.de>2021-03-04 13:57:43 +0100
commit846c3f4420e67613c2a6a359d4b117ac942200b8 (patch)
treee7ef66c8f43554261f673ff44cba3812f1510962 /lib
parent9bf7d10f3310147c7e85330a79da655b9f7a5bad (diff)
Modelfunction.from_json_maybe: Handle "old" data format with "static" key
Diffstat (limited to 'lib')
-rw-r--r--lib/functions.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/functions.py b/lib/functions.py
index 7950b5a..3031a01 100644
--- a/lib/functions.py
+++ b/lib/functions.py
@@ -187,6 +187,16 @@ class ModelFunction:
def from_json_maybe(cls, json_wrapped: dict, attribute: str):
# Legacy Code for PTA / tests. Do not use.
if type(json_wrapped) is dict and attribute in json_wrapped:
+ # benchmark data obtained before 2021-03-04 uses {"power": {"static": 0}}
+ # benchmark data obtained after 2021-03-04 uses {"power": {"type": "static", "value": 0}}
+ # from_json expects the latter.
+ if (
+ "static" in json_wrapped[attribute]
+ and "type" not in json_wrapped[attribute]
+ ):
+ json_wrapped[attribute]["type"] = "static"
+ json_wrapped[attribute]["value"] = json_wrapped[attribute]["static"]
+ json_wrapped[attribute].pop("static")
return cls.from_json(json_wrapped[attribute])
return StaticFunction(0)