Skip to content

Commit f056cf0

Browse files
authored
fix: S3 upload structure (add collection folder) (#193)
* fix: retry 5 times + wait 45 sec for DAAC * feat: make re-try configurable * feat: adding fastapi (in-progress) * fix: get collection creation working (in-progress) * feat: add collection folder in s3 upload * fix: update note * fix: update wrong PR number * fix: update missed file during merge * fix: remove old test case
1 parent 9972783 commit f056cf0

File tree

7 files changed

+19
-13
lines changed

7 files changed

+19
-13
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [5.2.3] - 2023-08-07
9+
### Changed
10+
- [#193](https://github.com/unity-sds/unity-data-services/pull/193) fix: add collection folder in s3 upload
11+
812
## [5.2.2] - 2023-07-21
913
### Changed
1014
- [#188](https://github.com/unity-sds/unity-data-services/pull/188) fix: Update stage out task to read STAC items from STAC catalog

cumulus_lambda_functions/stage_in_out/catalog_granules_unity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def __set_props_from_env(self):
3232
self.__provider_id = os.environ.get(self.PROVIDER_ID_KEY)
3333
self.__verify_ssl = os.environ.get(self.VERIFY_SSL_KEY, 'TRUE').strip().upper() == 'TRUE'
3434
self.__delaying_second = int(os.environ.get(self.DELAY_SECOND, '30'))
35-
self.__repeating_times = int(os.environ.get(self.REPEAT_TIMES, '30'))
35+
self.__repeating_times = int(os.environ.get(self.REPEAT_TIMES, '5'))
3636
self.__verify_ssl = os.environ.get(self.VERIFY_SSL_KEY, 'TRUE').strip().upper() == 'TRUE'
3737
return self
3838

cumulus_lambda_functions/stage_in_out/upload_granules_by_complete_catalog_s3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def upload(self, **kwargs) -> str:
6262
uploading_current_granule_stac = None
6363
for asset_type, asset_href in current_assets.items():
6464
LOGGER.debug(f'uploading {asset_type}, {asset_href}')
65-
s3_url = self.__s3.upload(asset_href, self.__staging_bucket, f'{self.__collection_id}:{current_granule_id}', self.__delete_files)
65+
s3_url = self.__s3.upload(asset_href, self.__staging_bucket, f'{self.__collection_id}/{self.__collection_id}:{current_granule_id}', self.__delete_files)
6666
if asset_href == each_child:
6767
uploading_current_granule_stac = s3_url
6868
updating_assets[asset_type] = s3_url

cumulus_lambda_functions/uds_api/dapa/collections_dapa_creation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,4 @@ def start(self, current_url: URL):
142142
'body': json.dumps({
143143
'message': 'processing'
144144
})
145-
}
145+
}

cumulus_lambda_functions/uds_api/web_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ async def root(request: Request):
3131

3232
if __name__ == '__main__':
3333
uvicorn.run("web_service:app", port=8005, log_level="info", reload=True)
34-
print("running")
34+
print("running")

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
setup(
2424
name="cumulus_lambda_functions",
25-
version="5.3.0",
25+
version="5.2.3",
2626
packages=find_packages(),
2727
install_requires=install_requires,
2828
tests_require=['mock', 'nose', 'sphinx', 'sphinx_rtd_theme', 'coverage', 'pystac', 'python-dotenv', 'jsonschema'],

tests/integration_tests/test_docker_entry.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,10 +1790,10 @@ def test_03_upload_complete_catalog(self):
17901790
self.assertTrue('metadata__cas' in upload_result['assets'], 'missing assets#metadata__cas')
17911791
self.assertTrue('href' in upload_result['assets']['metadata__cas'], 'missing assets#metadata__cas#href')
17921792
self.assertTrue(
1793-
upload_result['assets']['metadata__cas']['href'].startswith(f's3://{os.environ["STAGING_BUCKET"]}/'))
1793+
upload_result['assets']['metadata__cas']['href'].startswith(f's3://{os.environ["STAGING_BUCKET"]}/{os.environ["COLLECTION_ID"]}/'))
17941794
self.assertTrue('data' in upload_result['assets'], 'missing assets#data')
17951795
self.assertTrue('href' in upload_result['assets']['data'], 'missing assets#data#href')
1796-
self.assertTrue(upload_result['assets']['data']['href'].startswith(f's3://{os.environ["STAGING_BUCKET"]}/'))
1796+
self.assertTrue(upload_result['assets']['data']['href'].startswith(f's3://{os.environ["STAGING_BUCKET"]}/{os.environ["COLLECTION_ID"]}/'))
17971797
self.assertTrue(FileUtils.file_exist(os.environ['OUTPUT_FILE']), f'missing output file')
17981798
"""
17991799
Example output:
@@ -1808,11 +1808,11 @@ def test_03_upload_complete_catalog(self):
18081808
'updated': '2022-03-23T15:48:21.578000Z', 'datetime': '1970-01-01T00:00:00Z'},
18091809
'geometry': {'type': 'Point', 'coordinates': [0.0, 0.0]}, 'links': [],
18101810
'assets': {'data': {
1811-
'href': 's3://uds-test-cumulus-staging/NEW_COLLECTION_EXAMPLE_L1B___9:test_file01/test_file01.nc',
1811+
'href': 's3://uds-test-cumulus-staging/NEW_COLLECTION_EXAMPLE_L1B___9/NEW_COLLECTION_EXAMPLE_L1B___9:test_file01/test_file01.nc',
18121812
'title': 'main data'}, 'metadata__cas': {
1813-
'href': 's3://uds-test-cumulus-staging/NEW_COLLECTION_EXAMPLE_L1B___9:test_file01/test_file01.nc.cas',
1813+
'href': 's3://uds-test-cumulus-staging/NEW_COLLECTION_EXAMPLE_L1B___9/NEW_COLLECTION_EXAMPLE_L1B___9:test_file01/test_file01.nc.cas',
18141814
'title': 'metadata cas'}, 'metadata__stac': {
1815-
'href': 's3://uds-test-cumulus-staging/NEW_COLLECTION_EXAMPLE_L1B___9:test_file01/test_file01.nc.stac.json',
1815+
'href': 's3://uds-test-cumulus-staging/NEW_COLLECTION_EXAMPLE_L1B___9/NEW_COLLECTION_EXAMPLE_L1B___9:test_file01/test_file01.nc.stac.json',
18161816
'title': 'metadata stac'}},
18171817
'bbox': [0.0, 0.0, 0.0, 0.0],
18181818
'stac_extensions': [],
@@ -1887,11 +1887,11 @@ def test_04_catalog_from_file_item_collection(self):
18871887
'created': '2016-02-01T02:45:59.639000Z', 'updated': '2022-03-23T15:48:21.578000Z',
18881888
'datetime': '1970-01-01T00:00:00Z'}, 'geometry': {'type': 'Point', 'coordinates': [0.0, 0.0]},
18891889
'links': [], 'assets': {
1890-
'data': {'href': 's3://uds-test-cumulus-staging/NEW_COLLECTION_EXAMPLE_L1B___9:test_file01/test_file01.nc',
1890+
'data': {'href': 's3://uds-test-cumulus-staging/NEW_COLLECTION_EXAMPLE_L1B___9/NEW_COLLECTION_EXAMPLE_L1B___9:test_file01/test_file01.nc',
18911891
'title': 'main data'}, 'metadata__cas': {
1892-
'href': 's3://uds-test-cumulus-staging/NEW_COLLECTION_EXAMPLE_L1B___9:test_file01/test_file01.nc.cas',
1892+
'href': 's3://uds-test-cumulus-staging/NEW_COLLECTION_EXAMPLE_L1B___9/NEW_COLLECTION_EXAMPLE_L1B___9:test_file01/test_file01.nc.cas',
18931893
'title': 'metadata cas'}, 'metadata__stac': {
1894-
'href': 's3://uds-test-cumulus-staging/NEW_COLLECTION_EXAMPLE_L1B___9:test_file01/test_file01.nc.stac.json',
1894+
'href': 's3://uds-test-cumulus-staging/NEW_COLLECTION_EXAMPLE_L1B___9/NEW_COLLECTION_EXAMPLE_L1B___9:test_file01/test_file01.nc.stac.json',
18951895
'title': 'metadata stac'}}, 'bbox': [0.0, 0.0, 0.0, 0.0], 'stac_extensions': [],
18961896
'collection': 'NEW_COLLECTION_EXAMPLE_L1B___9'}]}
18971897
os.environ[Constants.USERNAME] = '/unity/uds/user/wphyo/username'
@@ -1903,6 +1903,8 @@ def test_04_catalog_from_file_item_collection(self):
19031903
os.environ['VERIFY_SSL'] = 'FALSE'
19041904
os.environ['PROVIDER_ID'] = 'SNPP'
19051905
os.environ['GRANULES_CATALOG_TYPE'] = 'UNITY'
1906+
os.environ['DELAY_SECOND'] = '35'
1907+
os.environ['REPEAT_TIMES'] = '3'
19061908
if len(argv) > 1:
19071909
argv.pop(-1)
19081910
argv.append('CATALOG')

0 commit comments

Comments
 (0)