diff --git a/bob/ip/binseg/data/dataset.py b/bob/ip/binseg/data/dataset.py index 7756b01de1b4f57ecce4764e027544fc742ac937..dd6cb14069237e2935de2814c21102888c6a55e3 100644 --- a/bob/ip/binseg/data/dataset.py +++ b/bob/ip/binseg/data/dataset.py @@ -116,14 +116,15 @@ class JSONDataset: samples = samples[:limit] for pos, sample in enumerate(samples): try: - assert len(sample) == len(self.fieldnames), ( - f"Entry {pos} in subset {name} of protocol " - f"{proto} has {len(sample)} entries instead of " - f"{len(self.fieldnames)} (expected). Fix file " - f"'{self._protocols[proto]}'" - ) - sample.data # check data can be loaded + sample.data # may trigger data loading logger.info(f"{sample.key}: OK") + except Exception as e: + logger.error( + f"Found error loading entry {pos} in subset {name} " + f"of protocol {proto} from file " + f"'{self._protocols[proto]}': {e}" + ) + errors += 1 except Exception as e: logger.error(f"{sample.key}: {e}") errors += 1 @@ -257,15 +258,13 @@ class CSVDataset: samples = samples[:limit] for pos, sample in enumerate(samples): try: - assert len(sample) == len(self.fieldnames), ( - f"Entry {pos} in subset {name} has {len(sample)} " - f"entries instead of {len(self.fieldnames)} " - f"(expected). Fix file '{self._subsets[name]}'" - ) - sample.data # triggers loading + sample.data # may trigger data loading logger.info(f"{sample.key}: OK") except Exception as e: - logger.error(f"{sample.key}: {e}") + logger.error( + f"Found error loading entry {pos} in subset {name} " + f"from file '{self._subsets[name]}': {e}" + ) errors += 1 return errors diff --git a/bob/ip/binseg/test/test_csv.py b/bob/ip/binseg/test/test_dataset.py similarity index 98% rename from bob/ip/binseg/test/test_csv.py rename to bob/ip/binseg/test/test_dataset.py index 1d8e22fcd2075cf0ce8bc58cc884cf506a79010f..f06d1a4ab2fe6d313af6d65ba5d81529daa6ca71 100644 --- a/bob/ip/binseg/test/test_csv.py +++ b/bob/ip/binseg/test/test_dataset.py @@ -45,6 +45,7 @@ def test_csv_loading(): ) dataset = CSVDataset(subsets, fieldnames, _raw_data_loader) + dataset.check() data = dataset.subsets() @@ -78,6 +79,7 @@ def test_json_loading(): ) dataset = JSONDataset(protocols, fieldnames, _raw_data_loader) + dataset.check() data = dataset.subsets("default")