1212)
1313from common .aws_s3_utils import move_file
1414from common .clients import get_s3_client , logger
15+ from common .models .batch_constants import ACK_BUCKET_NAME , SOURCE_BUCKET_NAME
1516from constants import (
1617 ACK_HEADERS ,
1718 BATCH_FILE_ARCHIVE_DIR ,
1819 BATCH_FILE_PROCESSING_DIR ,
1920 COMPLETED_ACK_DIR ,
2021 TEMP_ACK_DIR ,
21- get_ack_bucket_name ,
22- get_source_bucket_name ,
2322)
2423from logging_decorators import complete_batch_file_process_logging_decorator
2524
@@ -71,10 +70,8 @@ def complete_batch_file_process(
7170 the audit table status"""
7271 ack_filename = f"{ file_key .replace ('.csv' , f'_BusAck_{ created_at_formatted_string } .csv' )} "
7372
74- move_file (get_ack_bucket_name (), f"{ TEMP_ACK_DIR } /{ ack_filename } " , f"{ COMPLETED_ACK_DIR } /{ ack_filename } " )
75- move_file (
76- get_source_bucket_name (), f"{ BATCH_FILE_PROCESSING_DIR } /{ file_key } " , f"{ BATCH_FILE_ARCHIVE_DIR } /{ file_key } "
77- )
73+ move_file (ACK_BUCKET_NAME , f"{ TEMP_ACK_DIR } /{ ack_filename } " , f"{ COMPLETED_ACK_DIR } /{ ack_filename } " )
74+ move_file (SOURCE_BUCKET_NAME , f"{ BATCH_FILE_PROCESSING_DIR } /{ file_key } " , f"{ BATCH_FILE_ARCHIVE_DIR } /{ file_key } " )
7875
7976 total_ack_rows_processed , total_failures = get_record_count_and_failures_by_message_id (message_id )
8077 change_audit_table_status_to_processed (file_key , message_id )
@@ -99,7 +96,7 @@ def obtain_current_ack_content(temp_ack_file_key: str) -> StringIO:
9996 """Returns the current ack file content if the file exists, or else initialises the content with the ack headers."""
10097 try :
10198 # If ack file exists in S3 download the contents
102- existing_ack_file = get_s3_client ().get_object (Bucket = get_ack_bucket_name () , Key = temp_ack_file_key )
99+ existing_ack_file = get_s3_client ().get_object (Bucket = ACK_BUCKET_NAME , Key = temp_ack_file_key )
103100 existing_content = existing_ack_file ["Body" ].read ().decode ("utf-8" )
104101 except ClientError as error :
105102 # If ack file does not exist in S3 create a new file containing the headers only
@@ -132,7 +129,6 @@ def update_ack_file(
132129 accumulated_csv_content .write (cleaned_row + "\n " )
133130
134131 csv_file_like_object = BytesIO (accumulated_csv_content .getvalue ().encode ("utf-8" ))
135- ack_bucket_name = get_ack_bucket_name ()
136132
137- get_s3_client ().upload_fileobj (csv_file_like_object , ack_bucket_name , temp_ack_file_key )
138- logger .info ("Ack file updated to %s: %s" , ack_bucket_name , completed_ack_file_key )
133+ get_s3_client ().upload_fileobj (csv_file_like_object , ACK_BUCKET_NAME , temp_ack_file_key )
134+ logger .info ("Ack file updated to %s: %s" , ACK_BUCKET_NAME , completed_ack_file_key )
0 commit comments