forked from nasa/cumulus-message-adapter-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
task.py
executable file
·30 lines (23 loc) · 895 Bytes
/
task.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import os
import sys
from run_cumulus_task import run_cumulus_task
from cumulus_logger import CumulusLogger
logger = CumulusLogger(name="log_name")
schemas = {
"input": "schemas/input.json",
"config": "schemas/config.json",
"output": "schemas/output.json"
}
def task(event, context):
"""simple task that returns the updated event"""
# example logging inside of a task using CumulusLogger
logger.info('task executed')
# log error when an exception is caught
logger.error("task formatted message {} exc_info ", "bar", exc_info=True)
# return the output of the task
return { "goodbye": event["input"]["hello"] }
def handler(event, context):
"""handler that is provided to aws lambda"""
# make sure event & context metadata are set in the logger
logger.setMetadata(event, context)
return run_cumulus_task(task, event, context, schemas)