Skip to content

Commit d498fe3

Browse files
authored
fix: Completed.granules.only + validate start + end time for STAC (#93)
* feat: add completed status on granules * fix: check start & end datetime before pushing add them to stac + defaulted it to unix 0
1 parent 6e1345d commit d498fe3

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

ci.cd/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ build_lambda:
1515
docker run --rm -v `PWD`:"/usr/src/app/cumulus_lambda_functions":z -w "/usr/src/app/cumulus_lambda_functions" cae-artifactory.jpl.nasa.gov:17001/python:3.9 ci.cd/create_s3_zip.sh
1616

1717
build_lambda_public:
18-
docker run --rm -v `PWD`:"/usr/src/app/cumulus_lambda_functions":z -w "/usr/src/app/cumulus_lambda_functions" python:3.7 ci.cd/create_s3_zip.sh
18+
docker run --rm -v `PWD`:"/usr/src/app/cumulus_lambda_functions":z -w "/usr/src/app/cumulus_lambda_functions" python:3.9 ci.cd/create_s3_zip.sh
1919

2020
upload_lambda:
2121
aws --profile saml-pub s3 cp cumulus_lambda_functions_deployment.zip s3://am-uds-dev-cumulus-tf-state/unity_cumulus_lambda/

cumulus_lambda_functions/cumulus_stac/item_transformer.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,11 @@ def __get_assets(self, input_dict):
330330
}
331331
return asset_dict
332332

333+
def __get_datetime_from_source(self, source: dict, datetime_key: str):
334+
if datetime_key not in source:
335+
return '1970-01-01T00:00:00Z'
336+
return f"{source[datetime_key]}{'' if source[datetime_key].endswith('Z') else 'Z'}"
337+
333338
def to_stac(self, source: dict) -> dict:
334339
"""
335340
Sample: Cumulus granule
@@ -409,10 +414,10 @@ def to_stac(self, source: dict) -> dict:
409414
},
410415
"properties": {
411416
"datetime": f"{TimeUtils.decode_datetime(source['createdAt'], False)}Z",
412-
"start_datetime": f"{source['beginningDateTime']}{'' if source['beginningDateTime'].endswith('Z') else 'Z'}",
413-
"end_datetime": f"{source['endingDateTime']}{'' if source['endingDateTime'].endswith('Z') else 'Z'}",
417+
"start_datetime": self.__get_datetime_from_source(source, 'beginningDateTime'),
418+
"end_datetime": self.__get_datetime_from_source(source, 'endingDateTime'),
419+
"created": self.__get_datetime_from_source(source, 'productionDateTime'),
414420
# "created": source['processingEndDateTime'], # TODO
415-
"created": source['productionDateTime'], # TODO
416421
},
417422
"collection": source['collectionId'],
418423
"links": [

cumulus_lambda_functions/cumulus_wrapper/cumulus_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def __init__(self, cumulus_base: str, cumulus_token: str):
1212
self.__base_headers = {
1313
'Authorization': f'Bearer {cumulus_token}'
1414
}
15-
self._conditions = []
15+
self._conditions = ['status=completed']
1616

1717
def with_page_number(self, page_number):
1818
self._conditions.append(f'page={page_number}')

0 commit comments

Comments
 (0)