diff --git a/streamlit/interface_1.py b/streamlit/interface_1.py index 465ea9b..a714956 100644 --- a/streamlit/interface_1.py +++ b/streamlit/interface_1.py @@ -97,7 +97,10 @@ if client: batch_list = [] for prefix in batch_objects['CommonPrefixes']: - batch_list.append(prefix['Prefix'][:-1].split('/')[-1]) + batch_name = prefix['Prefix'][:-1].split('/')[-1] + batch_objects2 = s3_client.list_objects_v2(Bucket=client_bucket, Prefix="contracts-landing-zone/"+batch_name+"/", Delimiter='/') + if 'Contents' in batch_objects2 and len(batch_objects2['Contents'] > 0): + batch_list.append(prefix['Prefix'][:-1].split('/')[-1]) # Hardcoded batch_list for testing purposes # batch_list = ['batch_020524103737', 'batch_090524131433', 'batch_090524131607', 'batch_100524123000', 'batch_130524064322', @@ -252,36 +255,36 @@ if client: "contract_list": contract_list } -buttons = st.columns([0.8, 0.2]) -with buttons[0]: - st.download_button("Download Table", csv, "file.csv", "text/csv", key='download-csv') -with buttons[1]: - if st.button("Run Doczy.AI Pipeline"): - if not st.session_state.contract_count == len(edited_df): - st.error("Select at least one Group No. for every Contract") - else: - #Resets the Data Editor with Blank Values - with st.spinner('Running...'): - # csv_buf = StringIO() - # additional_info.to_csv(csv_buf, header=True, index=False) - # csv_buf.seek(0) - # s3_client.put_object(Bucket='doczy-dev-infra-raw-data-ingestion', Body=csv_buf.getvalue(), Key='training_interface/request_submission.csv') - # csv_buf = StringIO() - # edited_df.to_csv(csv_buf, header=True, index=False) - # csv_buf.seek(0) - # s3_client.put_object(Bucket='doczy-dev-infra-raw-data-ingestion', Body=csv_buf.getvalue(), Key='training_interface/contract_config.csv') - # try: - # save_to_sf('load_request_and_contract_submissions', request_submission_file_name = "request_submission.csv", contract_config_file_name = "contract_config.csv") - # except Exception as e: - # st.write(e) - response = requests.post(doczy_pipeline, json = myobj) - if response.status_code >= 200 and response.status_code < 300: - st.write("Success") - #Updates and Reruns the Code after everything on the interface has completed - update_dataframe() - st.rerun() - # st.write(myobj) + buttons = st.columns([0.8, 0.2]) + with buttons[0]: + st.download_button("Download Table", csv, "file.csv", "text/csv", key='download-csv') + with buttons[1]: + if st.button("Run Doczy.AI Pipeline"): + if not st.session_state.contract_count == len(edited_df): + st.error("Select at least one Group No. for every Contract") else: - st.write("Failed") - # st.write(response.text) + #Resets the Data Editor with Blank Values + with st.spinner('Running...'): + # csv_buf = StringIO() + # additional_info.to_csv(csv_buf, header=True, index=False) + # csv_buf.seek(0) + # s3_client.put_object(Bucket='doczy-dev-infra-raw-data-ingestion', Body=csv_buf.getvalue(), Key='training_interface/request_submission.csv') + # csv_buf = StringIO() + # edited_df.to_csv(csv_buf, header=True, index=False) + # csv_buf.seek(0) + # s3_client.put_object(Bucket='doczy-dev-infra-raw-data-ingestion', Body=csv_buf.getvalue(), Key='training_interface/contract_config.csv') + # try: + # save_to_sf('load_request_and_contract_submissions', request_submission_file_name = "request_submission.csv", contract_config_file_name = "contract_config.csv") + # except Exception as e: + # st.write(e) + response = requests.post(doczy_pipeline, json = myobj) + if response.status_code >= 200 and response.status_code < 300: + st.write("Success") + #Updates and Reruns the Code after everything on the interface has completed + update_dataframe() + st.rerun() + # st.write(myobj) + else: + st.write("Failed") + # st.write(response.text)