Skip to content

Commit

Permalink
Pass task output in standard CMA format
Browse files Browse the repository at this point in the history
  • Loading branch information
reweeden committed Nov 13, 2024
1 parent 60e7e0d commit 00adf4f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/granule_to_sns.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ def generate_message(granule: dict) -> dict:


def granule_to_sns(event: dict, _) -> dict:
client = boto3.client("sns")
granules = event["input"]["granules"]
payload = event["input"]

granules = payload["granules"]

client = boto3.client("sns")
sns_topic_arn = os.getenv("SNS_TOPIC_ARN")

for granule in granules:
Expand All @@ -46,10 +48,10 @@ def granule_to_sns(event: dict, _) -> dict:
},
)

return event
return payload


def lambda_handler(event, context):
def lambda_handler(event: dict, context) -> dict:
init_root_logger()
with log_errors():
return run_cumulus_task(granule_to_sns, event, context)
3 changes: 1 addition & 2 deletions tests/test_granule_to_sns.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import boto3
import pytest

from granule_to_sns import generate_message, granule_to_sns

Check warning on line 3 in tests/test_granule_to_sns.py

View workflow job for this annotation

GitHub Actions / flake8

isort expected 1 blank line in imports, found 0


Expand Down Expand Up @@ -105,4 +104,4 @@ def test_generate_message(event, message):

def test_granule_to_sns(sns_client, event, mocker):
mocker.patch.object(sns_client, "publish", return_value={})
assert granule_to_sns(event, None) == event
assert granule_to_sns(event, None) == event["input"]

0 comments on commit 00adf4f

Please sign in to comment.