Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

feat: add exception handling to _unzip method in build_data.py to con… #4572

Merged
merged 2 commits into from
Jun 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions parlai/core/build_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,13 @@ def _unzip(path, fname, delete=True):
PathManager.mkdirs(outpath)
continue
logging.debug(f"Extracting to {outpath}")
with zf.open(member, 'r') as inf, PathManager.open(outpath, 'wb') as outf:
shutil.copyfileobj(inf, outf)
try:
with zf.open(member, 'r') as inf, PathManager.open(
outpath, 'wb'
) as outf:
shutil.copyfileobj(inf, outf)
except FileNotFoundError:
logging.error(f"Failed to open ${member} and extract to ${outpath}")
if delete:
try:
PathManager.rm(fullpath)
Expand Down