From a21b5e46a52e82ca7f63847e2571fcf7b6a4bf1b Mon Sep 17 00:00:00 2001 From: Pratham Soni Date: Wed, 5 Jun 2024 12:00:54 -0500 Subject: [PATCH] pratham hardcoding comments --- streamlit/interface_0.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/streamlit/interface_0.py b/streamlit/interface_0.py index e0c0e63..217b31f 100644 --- a/streamlit/interface_0.py +++ b/streamlit/interface_0.py @@ -83,6 +83,7 @@ df['Contract Name'] = file_list file_names = [] buttons = st.columns([0.4, 0.4, 0.2]) with buttons[1]: + #Use the st.session_state to handle the changes that are made when create batch button is pressed if st.button("Create Batch"): # RECOMMENDATION - Use on-click to handle everything below this. Better in terms of re-running code. myobj = { "client-bucket-name": client_bucket } @@ -98,11 +99,16 @@ with buttons[1]: landing_zone = 'contracts_landing_zone' else: st.write("Failed") + #Consider using a batch upload and upload all the files to the s3 client bucket at the same time instead of a for loop to improve effeciency for uploaded_file in file_list: + #Using BytesIO seems unnecessary, and will cause processing delays, instead handle the stream directly stringio = BytesIO(uploaded_file.getvalue()) stringio.seek(0) s3_client.put_object(Bucket=client_bucket, Body=stringio.getvalue(), Key= landing_zone+batch_id+'/'+str(uploaded_file.name)) + #s3_client.put_object(Bucket=client_bucket, Body=uploaded_file, + # Key=landing_zone+batch_id+'/'+str(uploaded_file.name)) + # TODO: Test this insert function with snowflake upload_log = insert_upload_logs(batch_id, client, str(uploaded_file.name), datetime.now().strftime("%Y-%m-%d %H:%M:%S"), user_mail)