diff options
author | Daniel Friesel <daniel.friesel@uos.de> | 2021-03-08 16:13:16 +0100 |
---|---|---|
committer | Daniel Friesel <daniel.friesel@uos.de> | 2021-03-08 16:13:16 +0100 |
commit | d1e363c14fd08aa2aeb96e9b04980f4ee5750010 (patch) | |
tree | b885b1e6df6b6b07733b6fe15623652ceba27f08 /lib/loader.py | |
parent | c5724cc3988b064730de57a04e72a9168455bc12 (diff) |
loader: minor cleanup
Diffstat (limited to 'lib/loader.py')
-rw-r--r-- | lib/loader.py | 36 |
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) |