|
1 | 1 | """Functions for uploading the data to the ack file""" |
2 | 2 |
|
3 | | -import json |
4 | 3 | from io import StringIO, BytesIO |
5 | 4 | from typing import Union, Optional |
6 | 5 | from botocore.exceptions import ClientError |
7 | | -from constants import ACK_HEADERS, get_source_bucket_name, get_ack_bucket_name, FILE_NAME_PROC_LAMBDA_NAME |
8 | | -from audit_table import change_audit_table_status_to_processed, get_next_queued_file_details |
9 | | -from clients import get_s3_client, logger, lambda_client |
| 6 | +from constants import ACK_HEADERS, get_source_bucket_name, get_ack_bucket_name |
| 7 | +from audit_table import change_audit_table_status_to_processed |
| 8 | +from clients import get_s3_client, logger |
10 | 9 | from utils_for_ack_lambda import get_row_count |
11 | 10 | from logging_decorators import upload_ack_file_logging_decorator |
12 | 11 |
|
@@ -96,12 +95,9 @@ def upload_ack_file( |
96 | 95 | move_file(ack_bucket_name, temp_ack_file_key, archive_ack_file_key) |
97 | 96 | move_file(source_bucket_name, f"processing/{file_key}", f"archive/{file_key}") |
98 | 97 |
|
99 | | - # Update the audit table and invoke the filename lambda with next file in the queue (if one exists) |
| 98 | + # Update the audit table |
100 | 99 | change_audit_table_status_to_processed(file_key, message_id) |
101 | | - supplier_queue = f"{supplier}_{vaccine_type}" |
102 | | - next_queued_file_details = get_next_queued_file_details(supplier_queue) |
103 | | - if next_queued_file_details: |
104 | | - invoke_filename_lambda(next_queued_file_details["filename"], next_queued_file_details["message_id"]) |
| 100 | + |
105 | 101 | # Ingestion of this file is complete |
106 | 102 | result = { |
107 | 103 | "message_id": message_id, |
@@ -149,27 +145,3 @@ def move_file(bucket_name: str, source_file_key: str, destination_file_key: str) |
149 | 145 | ) |
150 | 146 | s3_client.delete_object(Bucket=bucket_name, Key=source_file_key) |
151 | 147 | logger.info("File moved from %s to %s", source_file_key, destination_file_key) |
152 | | - |
153 | | - |
154 | | -def invoke_filename_lambda(file_key: str, message_id: str) -> None: |
155 | | - """Invokes the filenameprocessor lambda with the given file key and message id""" |
156 | | - try: |
157 | | - lambda_payload = { |
158 | | - "Records": [ |
159 | | - {"s3": |
160 | | - { |
161 | | - "bucket": { |
162 | | - "name": get_source_bucket_name() |
163 | | - }, |
164 | | - "object": {"key": file_key} |
165 | | - }, |
166 | | - "message_id": message_id |
167 | | - } |
168 | | - ] |
169 | | - } |
170 | | - lambda_client.invoke( |
171 | | - FunctionName=FILE_NAME_PROC_LAMBDA_NAME, InvocationType="Event", Payload=json.dumps(lambda_payload) |
172 | | - ) |
173 | | - except Exception as error: |
174 | | - logger.error("Error invoking filename lambda: %s", error) |
175 | | - raise |
0 commit comments