Skip to content

Commit 937b8e9

Browse files
authored
fix: Add default version during stageout collection id transformation (#61)
* feat: add AUDIT log level for upload * chore: update outdated tests * fix: allow empty str as RESULT_PATH_PREFIX & replace w/ default val * feat: add default version when needed
1 parent 4e9425a commit 937b8e9

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

mdps_ds_lib/lib/cumulus_stac/granules_catalog.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ def get_unity_formatted_collection_id(current_collection_id: str, project_venue_
1616
collection_identifier_parts = current_collection_id.split(':')
1717
if len(collection_identifier_parts) >= 6:
1818
LOGGER.debug(f'current_collection_id is assumed to be in UNITY format: {current_collection_id}')
19+
current_collection_id = f'{current_collection_id}___001' if '___' not in current_collection_id else current_collection_id
1920
return current_collection_id
2021

2122
LOGGER.info(f'current_collection_id is not UNITY formatted ID: {current_collection_id}')
2223
if project_venue_set[0] is None or project_venue_set[1] is None:
2324
raise ValueError(f'missing project or venue in ENV which is needed due to current_collection_id not UNITY format: {project_venue_set}')
2425
new_collection = f'URN:NASA:UNITY:{project_venue_set[0]}:{project_venue_set[1]}:{current_collection_id}'
26+
new_collection = f'{new_collection}___001' if '___' not in new_collection else new_collection
2527
LOGGER.info(f'UNITY formatted ID: {new_collection}')
2628
return new_collection
2729

tests/mdps_ds_lib/lib/cumulus_stac/test_granules_catalog.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -929,10 +929,16 @@ def test_get_unity_formatted_collection_id(self):
929929
GranulesCatalog.get_unity_formatted_collection_id('NA', ('LOCAL', None))
930930
self.assertTrue(str(context.exception).startswith('missing project or venue'))
931931

932-
result = GranulesCatalog.get_unity_formatted_collection_id('NA', ('LOCAL', 'DEV'))
933-
self.assertEqual(result, 'URN:NASA:UNITY:LOCAL:DEV:NA', f'wrong collection id output')
932+
result = GranulesCatalog.get_unity_formatted_collection_id('NA__FOO', ('LOCAL', 'DEV'))
933+
self.assertEqual(result, 'URN:NASA:UNITY:LOCAL:DEV:NA__FOO___001', f'wrong collection id output')
934934

935935
result = GranulesCatalog.get_unity_formatted_collection_id('URN:JPL:IDS:LOCAL1:DEV2:A:B:C:D:E:F:G', ('LOCAL', 'DEV'))
936-
self.assertEqual(result, 'URN:JPL:IDS:LOCAL1:DEV2:A:B:C:D:E:F:G', f'wrong collection id output')
936+
self.assertEqual(result, 'URN:JPL:IDS:LOCAL1:DEV2:A:B:C:D:E:F:G___001', f'wrong collection id output')
937+
938+
result = GranulesCatalog.get_unity_formatted_collection_id('NA___HELLO', ('LOCAL', 'DEV'))
939+
self.assertEqual(result, 'URN:NASA:UNITY:LOCAL:DEV:NA___HELLO', f'wrong collection id output')
940+
941+
result = GranulesCatalog.get_unity_formatted_collection_id('URN:JPL:IDS:LOCAL1:DEV2:A:B:C:D:E:F:G___FOO', ('LOCAL', 'DEV'))
942+
self.assertEqual(result, 'URN:JPL:IDS:LOCAL1:DEV2:A:B:C:D:E:F:G___FOO', f'wrong collection id output')
937943

938944
return

0 commit comments

Comments
 (0)