From fd5dc88eba219b5356b362c44172fd435b69d2ea Mon Sep 17 00:00:00 2001 From: Jimmy Wei Date: Tue, 7 Jun 2022 13:36:32 -0400 Subject: [PATCH] =?UTF-8?q?feat:=20add=20exception=20handling=20to=20=5Fun?= =?UTF-8?q?zip=20method=20in=20build=5Fdata.py=20to=20con=E2=80=A6=20(#457?= =?UTF-8?q?2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add exception handling to _unzip method in build_data.py to continue execution even when some files fail to extract * fix lint error --- parlai/core/build_data.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/parlai/core/build_data.py b/parlai/core/build_data.py index 9cc422f4deb..06fb3b0fa86 100644 --- a/parlai/core/build_data.py +++ b/parlai/core/build_data.py @@ -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)