From 0cefdf2fac82fb999862c7a83bfd950893c5d901 Mon Sep 17 00:00:00 2001 From: Jeremy Turner Date: Wed, 21 Aug 2024 18:03:33 -0400 Subject: [PATCH] add try/except to avoid OSError when file is missing wanted variable group --- icepyx/core/read.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/icepyx/core/read.py b/icepyx/core/read.py index 088656abc..824b2aa74 100644 --- a/icepyx/core/read.py +++ b/icepyx/core/read.py @@ -628,9 +628,18 @@ def load(self): s3 = earthaccess.get_s3fs_session(daac="NSIDC") file = s3.open(file, "rb") - all_dss.append( - self._build_single_file_dataset(file, groups_list) - ) # wanted_groups, vgrp.keys())) + try: + all_dss.append( + self._build_single_file_dataset(file, groups_list) + ) # wanted_groups, vgrp.keys())) + except OSError as oe: + warnings.warn( + f"{file} is excluded from this dataset because it" + "did not contain all wanted variable groups," + f"causing the following error: {oe}", + stacklevel=2, + ) + continue # Closing the file prevents further operations on the dataset # from s3fs.core import S3File