Skip to content

Commit a538b50

Browse files
committed
log pickle errors during collection and indicate broken file name
1 parent 0486f6f commit a538b50

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

FastOMA/collect_subhogs.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,16 @@ def iter_hogs(pickle_folder: Path):
3434
for f in files:
3535
if f.startswith('file_') and f.endswith('.pickle'):
3636
with open(os.path.join(root, f), 'rb') as handle:
37-
cur = pickle.load(handle)
37+
try:
38+
cur = pickle.load(handle)
39+
except pickle.PickleError as e:
40+
logger.error("Error reading pickle file %s: %s", os.path.join(root, f), e)
41+
raise
3842
nr_hogs += len(cur)
3943
yield from cur
4044
cnt += 1
4145
if cnt % 500 == 0:
42-
logger.info("read %d batch pickle files so far, resulting in %d roothogs so far",
43-
cnt, nr_hogs)
46+
logger.info("read %d batch pickle files so far, resulting in %d roothogs so far", cnt, nr_hogs)
4447
logger.info("number of pickle files is %d.", cnt)
4548
logger.debug("number of hogs in all batches is %d", nr_hogs)
4649

0 commit comments

Comments
 (0)