From 065415ec7d810a1467636fe8a13de9a70fdf6a66 Mon Sep 17 00:00:00 2001 From: sudha-murthy <36246045+sudha-murthy@users.noreply.github.com> Date: Thu, 22 Aug 2024 11:09:15 -0400 Subject: [PATCH] "DAS-2192 - Ensure HOSS correctly identifies when an index range subset is necessary". * updates to prevent prefetch from being called for variable subset for SMAP L3/L4 collections * updates to prevent prefetch from being called for variable subset for SMAP L3/L4 collections * added couple of unit tests to is_index_subset function to test empty lists * updates based on PR feedback * updated CHANGELOG.md again --- CHANGELOG.md | 10 ++++++++ docker/service_version.txt | 2 +- hoss/dimension_utilities.py | 2 +- tests/unit/test_dimension_utilities.py | 32 ++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c1845e4..2a18ed7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ + +## v1.0.5 +### 2024-08-19 + +This version of HOSS updates the `is_index_subset` method to check for empty list (in case of dimensions subset) +as well as None (for the spatial, bbox and temporal subsets). This prevents 1-D dimension variables from being +unnecessarily requested from OPeNDAP for variable subsets which needs to be done only for spatial and temporal +subsetting requests. This also prevents a whole granule request when 1-D dimension variables were not present +in the granule. + ## v1.0.4 ### 2024-04-05 diff --git a/docker/service_version.txt b/docker/service_version.txt index ee90284..90a27f9 100644 --- a/docker/service_version.txt +++ b/docker/service_version.txt @@ -1 +1 @@ -1.0.4 +1.0.5 diff --git a/hoss/dimension_utilities.py b/hoss/dimension_utilities.py index 59fe6b0..9ee8d02 100644 --- a/hoss/dimension_utilities.py +++ b/hoss/dimension_utilities.py @@ -45,7 +45,7 @@ def is_index_subset(message: Message) -> bool: """ return any( - rgetattr(message, subset_parameter, None) is not None + rgetattr(message, subset_parameter, None) not in (None, []) for subset_parameter in [ 'subset.bbox', 'subset.shape', diff --git a/tests/unit/test_dimension_utilities.py b/tests/unit/test_dimension_utilities.py index 4e8d789..5ad7a21 100644 --- a/tests/unit/test_dimension_utilities.py +++ b/tests/unit/test_dimension_utilities.py @@ -679,6 +679,38 @@ def test_is_index_subset(self): ) ) + with self.subTest('Empty dimensions List'): + self.assertFalse( + is_index_subset( + Message( + { + 'subset': { + 'bbox': None, + 'shape_file': None, + 'dimensions': [], + }, + 'temporal': None, + } + ) + ) + ) + + with self.subTest('Dimensions Subset is not empty'): + self.assertTrue( + is_index_subset( + Message( + { + 'subset': { + 'bbox': None, + 'shape_file': None, + 'dimensions': dimensions, + }, + 'temporal': None, + } + ) + ) + ) + with self.subTest('Not an index range subset'): self.assertFalse(is_index_subset(Message({})))