Skip to content

Commit 8430800

Browse files
authored
feat: daac product.name = granule id (#589)
1 parent 01d41b4 commit 8430800

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

cumulus_lambda_functions/daac_archiver/daac_archiver_logic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def __extract_files(self, uds_cnm_json: dict, daac_config: dict):
9898

9999
def send_to_daac_internal(self, uds_cnm_json: dict):
100100
LOGGER.debug(f'uds_cnm_json: {uds_cnm_json}')
101-
granule_identifier = UdsCollections.decode_identifier(uds_cnm_json['identifier']) # This is normally meant to be for collection. Since our granule ID also has collection id prefix. we can use this.
101+
granule_identifier = UdsCollections.decode_granule_identifier(uds_cnm_json['identifier']) # This is normally meant to be for collection. Since our granule ID also has collection id prefix. we can use this.
102102
self.__archive_index_logic.set_tenant_venue(granule_identifier.tenant, granule_identifier.venue)
103103
daac_config = self.__archive_index_logic.percolate_document(uds_cnm_json['identifier'])
104104
if daac_config is None or len(daac_config) < 1:
@@ -120,7 +120,7 @@ def send_to_daac_internal(self, uds_cnm_json: dict):
120120
"provider": granule_identifier.tenant,
121121
"version": "1.6.0", # TODO this is hardcoded?
122122
"product": {
123-
"name": granule_identifier.id,
123+
"name": granule_identifier.granule,
124124
# "dataVersion": daac_config['daac_data_version'],
125125
'files': self.__extract_files(uds_cnm_json, daac_config),
126126
}

cumulus_lambda_functions/lib/uds_db/uds_collections.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313

1414
CollectionIdentifier = namedtuple('CollectionIdentifier', ['urn', 'nasa', 'project', 'tenant', 'venue', 'id'])
15+
GranuleIdentifier = namedtuple('CollectionIdentifier', ['urn', 'nasa', 'project', 'tenant', 'venue', 'id', 'granule'])
1516

1617

1718
class UdsCollections:
@@ -35,6 +36,14 @@ def decode_identifier(incoming_identifier: str) -> CollectionIdentifier:
3536
raise ValueError(f'invalid collection: {collection_identifier_parts}')
3637
return CollectionIdentifier._make(collection_identifier_parts[0:6])
3738

39+
@staticmethod
40+
def decode_granule_identifier(incoming_identifier: str) -> GranuleIdentifier:
41+
collection_identifier_parts = incoming_identifier.split(':')
42+
if len(collection_identifier_parts) < 7:
43+
raise ValueError(f'invalid collection: {collection_identifier_parts}')
44+
return GranuleIdentifier._make(collection_identifier_parts[0:6] + [':'.join(collection_identifier_parts[6:])])
45+
46+
3847
def __bbox_to_polygon(self, bbox: list):
3948
if len(bbox) != 4:
4049
raise ValueError(f'not bounding box: {bbox}')

tests/cumulus_lambda_functions/lib/uds_db/test_uds_collections.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,18 @@ def test_02(self):
2626
self.assertEqual(aa.venue, 'DEV', f'wrong venue')
2727
self.assertEqual(aa.tenant, 'UDS_LOCAL', f'wrong tenant')
2828
print(aa)
29+
30+
granule_id = 'URN:NASA:UNITY:unity:test:TRPSDL2ALLCRS1MGLOS___2:TROPESS_CrIS-JPSS1_L2_Standard_H2O_20250108_MUSES_R1p23_megacity_los_angeles_MGLOS_F2p5_J0'
31+
aa = UdsCollections.decode_granule_identifier(granule_id)
32+
self.assertEqual(aa.venue, 'test', f'wrong venue')
33+
self.assertEqual(aa.tenant, 'unity', f'wrong tenant')
34+
self.assertEqual(aa.granule, 'TROPESS_CrIS-JPSS1_L2_Standard_H2O_20250108_MUSES_R1p23_megacity_los_angeles_MGLOS_F2p5_J0')
35+
print(aa)
36+
granule_id = 'URN:NASA:UNITY:unity:test:TRPSDL2ALLCRS1MGLOS___2:TROPESS_CrIS-JPSS1_L2_Standard_H2O_20250108_MUSES_R1p23_megacity_los_angeles_MGLOS_F2p5_J0:1:2:3:4'
37+
aa = UdsCollections.decode_granule_identifier(granule_id)
38+
self.assertEqual(aa.venue, 'test', f'wrong venue')
39+
self.assertEqual(aa.tenant, 'unity', f'wrong tenant')
40+
self.assertEqual(aa.granule, 'TROPESS_CrIS-JPSS1_L2_Standard_H2O_20250108_MUSES_R1p23_megacity_los_angeles_MGLOS_F2p5_J0:1:2:3:4')
41+
2942
return
3043

0 commit comments

Comments
 (0)