From 0f18d568de6b58738a4503ef831c390c90e132a9 Mon Sep 17 00:00:00 2001 From: Rachel Wegener Date: Thu, 2 Nov 2023 19:49:13 +0000 Subject: [PATCH] add warning if user is accessing data outside NSIDC bucket --- icepyx/core/validate_inputs.py | 13 +++++++++++++ icepyx/core/variables.py | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/icepyx/core/validate_inputs.py b/icepyx/core/validate_inputs.py index c7ba55a6d..d74768eea 100644 --- a/icepyx/core/validate_inputs.py +++ b/icepyx/core/validate_inputs.py @@ -104,3 +104,16 @@ def tracks(track): warnings.warn("Listed Reference Ground Track is not available") return track_list + +def check_s3bucket(path): + """ + Check if the given path is an s3 path. Raise a warning if the data being referenced is not + in the NSIDC bucket + """ + split_path = path.split('/') + if split_path[0] == 's3:' and split_path[2] != 'nsidc-cumulus-prod-protected': + warnings.warn( + 's3 data being read from outside the NSIDC data bucket. Icepyx can ' + 'read this data, but available data lists may not be accurate.', stacklevel=2 + ) + return path diff --git a/icepyx/core/variables.py b/icepyx/core/variables.py index 3c649e33f..81bf65d0d 100644 --- a/icepyx/core/variables.py +++ b/icepyx/core/variables.py @@ -83,7 +83,7 @@ def __init__( # Set the product and version from either the input args or the file if path: - self._path = path + self._path = val.check_s3bucket(path) self._product = is2ref.extract_product(self._path, auth=self.auth) self._version = is2ref.extract_version(self._path, auth=self.auth) elif product: