Skip to content

Commit 743e7c1

Browse files
committed
merege
1 parent d916e0d commit 743e7c1

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

recordprocessor/src/utils_for_recordprocessor.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os
44
from csv import DictReader
55
from io import TextIOWrapper
6-
from clients import s3_client
6+
from clients import s3_client, logger
77

88

99
def get_environment() -> str:
@@ -28,3 +28,19 @@ def get_csv_content_dict_reader(file_key: str) -> DictReader:
2828
def create_diagnostics_dictionary(error_type, status_code, error_message) -> dict:
2929
"""Returns a dictionary containing the error_type, statusCode, and error_message"""
3030
return {"error_type": error_type, "statusCode": status_code, "error_message": error_message}
31+
32+
33+
def invoke_filename_lambda(file_key: str, message_id: str) -> None:
34+
"""Invokes the filenameprocessor lambda with the given file key and message id"""
35+
try:
36+
lambda_payload = {
37+
"Records": [
38+
{"s3": {"bucket": {"name": SOURCE_BUCKET_NAME}, "object": {"key": file_key}}, "message_id": message_id}
39+
]
40+
}
41+
lambda_client.invoke(
42+
FunctionName=FILE_NAME_PROC_LAMBDA_NAME, InvocationType="Event", Payload=json.dumps(lambda_payload)
43+
)
44+
except Exception as error:
45+
logger.error("Error invoking filename lambda: %s", error)
46+
raise

0 commit comments

Comments
 (0)