Skip to content

Commit

Permalink
/deploy sit
Browse files Browse the repository at this point in the history
  • Loading branch information
sliu008 committed Mar 28, 2024
1 parent bf59391 commit a2fa174
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
14 changes: 14 additions & 0 deletions podaac/lambda_handler/lambda_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,14 @@ def process(self):
granules = self.input['granules']
append_output = {}

if self.kwargs.get('context', None):
try:
aws_request_id = self.kwargs.get('context').aws_request_id
message = f"aws_request_id: {aws_request_id} collection: {self.config.get('collection')}"
self.logger.info(message)
except AttributeError:
pass

self.download_palette_files(config_file_path)

for granule in granules:
Expand Down Expand Up @@ -390,6 +398,12 @@ def image_generate(self, file_, config_file, palette_dir, granule_id):

return uploaded_files


@classmethod
def handler(cls, event, context=None, path=None, noclean=False):
""" General event handler """
return cls.run(path=path, noclean=noclean, context=context, **event)

@classmethod
def run(cls, *args, **kwargs):
""" Run this payload with the given Process class """
Expand Down
7 changes: 6 additions & 1 deletion tests/test_lambda_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ def test_get_config_no_setting():
# exception expected
pass

class Context:
def __init__(self, aws_request_id):
self.aws_request_id = aws_request_id


@mock_s3
@patch('requests.get')
Expand Down Expand Up @@ -233,7 +237,8 @@ def test_lambda_handler_cumulus(mocked_get):
is_valid_shema = validate(instance=files, schema=file_schema)
assert is_valid_shema is None

output = lambda_handler.handler(event, {})
context = Context("fake_request_id")
output = lambda_handler.handler(event, context)

for granule in output.get('payload').get('granules'):
is_valid_shema = validate(instance=granule.get('files'), schema=file_schema)
Expand Down

0 comments on commit a2fa174

Please sign in to comment.