diff --git a/cumulus_lambda_functions/daac_archiver/daac_archiver_logic.py b/cumulus_lambda_functions/daac_archiver/daac_archiver_logic.py index c0df7e2a..5e47771d 100644 --- a/cumulus_lambda_functions/daac_archiver/daac_archiver_logic.py +++ b/cumulus_lambda_functions/daac_archiver/daac_archiver_logic.py @@ -98,7 +98,7 @@ def __extract_files(self, uds_cnm_json: dict, daac_config: dict): def send_to_daac_internal(self, uds_cnm_json: dict): LOGGER.debug(f'uds_cnm_json: {uds_cnm_json}') - 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. + 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. self.__archive_index_logic.set_tenant_venue(granule_identifier.tenant, granule_identifier.venue) daac_config = self.__archive_index_logic.percolate_document(uds_cnm_json['identifier']) if daac_config is None or len(daac_config) < 1: @@ -120,7 +120,7 @@ def send_to_daac_internal(self, uds_cnm_json: dict): "provider": granule_identifier.tenant, "version": "1.6.0", # TODO this is hardcoded? "product": { - "name": granule_identifier.id, + "name": granule_identifier.granule, # "dataVersion": daac_config['daac_data_version'], 'files': self.__extract_files(uds_cnm_json, daac_config), } diff --git a/cumulus_lambda_functions/lib/uds_db/uds_collections.py b/cumulus_lambda_functions/lib/uds_db/uds_collections.py index a525f7c9..fb3e0dc2 100644 --- a/cumulus_lambda_functions/lib/uds_db/uds_collections.py +++ b/cumulus_lambda_functions/lib/uds_db/uds_collections.py @@ -12,6 +12,7 @@ CollectionIdentifier = namedtuple('CollectionIdentifier', ['urn', 'nasa', 'project', 'tenant', 'venue', 'id']) +GranuleIdentifier = namedtuple('CollectionIdentifier', ['urn', 'nasa', 'project', 'tenant', 'venue', 'id', 'granule']) class UdsCollections: @@ -35,6 +36,14 @@ def decode_identifier(incoming_identifier: str) -> CollectionIdentifier: raise ValueError(f'invalid collection: {collection_identifier_parts}') return CollectionIdentifier._make(collection_identifier_parts[0:6]) + @staticmethod + def decode_granule_identifier(incoming_identifier: str) -> GranuleIdentifier: + collection_identifier_parts = incoming_identifier.split(':') + if len(collection_identifier_parts) < 7: + raise ValueError(f'invalid collection: {collection_identifier_parts}') + return GranuleIdentifier._make(collection_identifier_parts[0:6] + [':'.join(collection_identifier_parts[6:])]) + + def __bbox_to_polygon(self, bbox: list): if len(bbox) != 4: raise ValueError(f'not bounding box: {bbox}') diff --git a/tests/cumulus_lambda_functions/lib/uds_db/test_uds_collections.py b/tests/cumulus_lambda_functions/lib/uds_db/test_uds_collections.py index 9efe82a5..eabbee1d 100644 --- a/tests/cumulus_lambda_functions/lib/uds_db/test_uds_collections.py +++ b/tests/cumulus_lambda_functions/lib/uds_db/test_uds_collections.py @@ -26,5 +26,18 @@ def test_02(self): self.assertEqual(aa.venue, 'DEV', f'wrong venue') self.assertEqual(aa.tenant, 'UDS_LOCAL', f'wrong tenant') print(aa) + + granule_id = 'URN:NASA:UNITY:unity:test:TRPSDL2ALLCRS1MGLOS___2:TROPESS_CrIS-JPSS1_L2_Standard_H2O_20250108_MUSES_R1p23_megacity_los_angeles_MGLOS_F2p5_J0' + aa = UdsCollections.decode_granule_identifier(granule_id) + self.assertEqual(aa.venue, 'test', f'wrong venue') + self.assertEqual(aa.tenant, 'unity', f'wrong tenant') + self.assertEqual(aa.granule, 'TROPESS_CrIS-JPSS1_L2_Standard_H2O_20250108_MUSES_R1p23_megacity_los_angeles_MGLOS_F2p5_J0') + print(aa) + 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' + aa = UdsCollections.decode_granule_identifier(granule_id) + self.assertEqual(aa.venue, 'test', f'wrong venue') + self.assertEqual(aa.tenant, 'unity', f'wrong tenant') + self.assertEqual(aa.granule, 'TROPESS_CrIS-JPSS1_L2_Standard_H2O_20250108_MUSES_R1p23_megacity_los_angeles_MGLOS_F2p5_J0:1:2:3:4') + return