diff options
author | Daniel Friesel <daniel.friesel@uos.de> | 2021-03-09 08:41:34 +0100 |
---|---|---|
committer | Daniel Friesel <daniel.friesel@uos.de> | 2021-03-09 08:41:34 +0100 |
commit | be77594187e203b92465b243e5860c89e5fc5cb8 (patch) | |
tree | e0d85920023f3eafa0eb793c6d2575c681c65cf7 | |
parent | 1dc94fc420371ab832ab7fa2d0a1f7177afb65a4 (diff) |
loader: do a cursory compatibility check before merging files
-rw-r--r-- | lib/loader.py | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/loader.py b/lib/loader.py index 43e267c..6e57134 100644 --- a/lib/loader.py +++ b/lib/loader.py @@ -243,6 +243,19 @@ def sanity_check_aggregate(aggregate): ) +def ptalogs_are_compatible(pl1, pl2): + assert pl1["pta"]["parameters"] == pl2["pta"]["parameters"] + if list(sorted(pl1["pta"]["state"].keys())) != list( + sorted(pl2["pta"]["state"].keys()) + ): + return False + if list(sorted(map(lambda t: t["name"], pl1["pta"]["transitions"]))) != list( + sorted(map(lambda t: t["name"], pl1["pta"]["transitions"])) + ): + return False + return True + + class RawData: """ Loader for hardware model traces measured with MIMOSA. @@ -335,10 +348,12 @@ class RawData: if self.ptalog and len(filenames) > 1: for filename in filenames[1:]: with tarfile.open(filename) as tf: - # TODO check compatibility - self.ptalog["files"].extend( - json.load(tf.extractfile(tf.getmember("ptalog.json")))["files"] - ) + new_ptalog = json.load(tf.extractfile(tf.getmember("ptalog.json"))) + if not ptalogs_are_compatible(self.ptalog, new_ptalog): + logger.warning( + f"Benchmarks {filenames[0]} and {filename} may be incompatible" + ) + self.ptalog["files"].extend(new_ptalog["files"]) self.set_cache_file() if not with_traces and not skip_cache: |