summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2021-03-08 16:13:16 +0100
committerDaniel Friesel <daniel.friesel@uos.de>2021-03-08 16:13:16 +0100
commitd1e363c14fd08aa2aeb96e9b04980f4ee5750010 (patch)
treeb885b1e6df6b6b07733b6fe15623652ceba27f08
parentc5724cc3988b064730de57a04e72a9168455bc12 (diff)
loader: minor cleanup
-rw-r--r--lib/loader.py36
1 files changed, 17 insertions, 19 deletions
diff --git a/lib/loader.py b/lib/loader.py
index f5c6306..acdee6b 100644
--- a/lib/loader.py
+++ b/lib/loader.py
@@ -343,16 +343,19 @@ class RawData:
def load_cache(self):
if os.path.exists(self.cache_file):
with open(self.cache_file, "r") as f:
- cache_data = json.load(f)
- self.filenames = cache_data["filenames"]
- self.traces = cache_data["traces"]
- self.preprocessing_stats = cache_data["preprocessing_stats"]
- if "pta" in cache_data:
- self.pta = cache_data["pta"]
- if "ptalog" in cache_data:
- self.ptalog = cache_data["ptalog"]
- self.setup_by_fileno = cache_data["setup_by_fileno"]
- self.preprocessed = True
+ try:
+ cache_data = json.load(f)
+ self.filenames = cache_data["filenames"]
+ self.traces = cache_data["traces"]
+ self.preprocessing_stats = cache_data["preprocessing_stats"]
+ if "pta" in cache_data:
+ self.pta = cache_data["pta"]
+ if "ptalog" in cache_data:
+ self.ptalog = cache_data["ptalog"]
+ self.setup_by_fileno = cache_data["setup_by_fileno"]
+ self.preprocessed = True
+ except json.decoder.JSONDecodeError as e:
+ logger.info(f"Skipping cache entry {self.cache_file}: {e}")
def save_cache(self):
if self.with_traces:
@@ -914,12 +917,10 @@ class RawData:
"""
if self.preprocessed:
return self.traces
- if self.version == 0:
- self._preprocess_012(0)
- elif self.version == 1:
- self._preprocess_012(1)
- elif self.version == 2:
- self._preprocess_012(2)
+ if self.version <= 2:
+ self._preprocess_012(self.version)
+ else:
+ raise ValueError(f"Unsupported raw data version: {self.version}")
self.preprocessed = True
self.save_cache()
return self.traces
@@ -1168,9 +1169,6 @@ class RawData:
if version == 0:
self.traces = self._concatenate_traces(self.traces_by_fileno)
elif version == 1:
- self.traces = self._concatenate_traces(
- map(lambda x: x["expected_trace"], measurements)
- )
self.traces = self._concatenate_traces(self.traces_by_fileno)
elif version == 2:
self.traces = self._concatenate_traces(self.traces_by_fileno)