From 672aceb72d0ff69aa21926279b025f793cc571a0 Mon Sep 17 00:00:00 2001 From: Pratham Soni Date: Thu, 20 Jun 2024 09:31:49 -0500 Subject: [PATCH 1/3] table reload when doczy pipeline has fully run --- streamlit/interface_1.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/streamlit/interface_1.py b/streamlit/interface_1.py index 25666d5..861e195 100644 --- a/streamlit/interface_1.py +++ b/streamlit/interface_1.py @@ -265,7 +265,6 @@ with buttons[1]: st.error("Select at least one Group No. for every Contract") else: #Resets the Data Editor with Blank Values - update_dataframe() with st.spinner('Running...'): # csv_buf = StringIO() # additional_info.to_csv(csv_buf, header=True, index=False) @@ -282,6 +281,9 @@ with buttons[1]: 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.experimental_rerun() # st.write(myobj) else: st.write("Failed") From 045737c186096e1069b5f36ffe3ccf187cda5d7f Mon Sep 17 00:00:00 2001 From: Pratham Soni Date: Thu, 20 Jun 2024 16:01:12 -0500 Subject: [PATCH 2/3] update dataframe on pipeline run --- streamlit/interface_1.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/streamlit/interface_1.py b/streamlit/interface_1.py index c788354..4bf6831 100644 --- a/streamlit/interface_1.py +++ b/streamlit/interface_1.py @@ -15,6 +15,11 @@ from constants import USER_LIST (REDIRECT_URI, create_batch_url, doczy_pipeline) = util.load_page_details(1) +def update_dataframe(): + new_df = pd.DataFrame(columns=['Contract Name', 'Unique Key','Pricing Before Carveouts' + , 'Contract Related', 'Provider', 'Timeline', 'Carveout Indicator', 'Carveout Methodology']) + st.session_state['dataframe'] = new_df + user_list = USER_LIST st.set_page_config(layout = "wide") # Sidebar contents @@ -272,7 +277,7 @@ with buttons[1]: st.write("Success") #Updates and Reruns the Code after everything on the interface has completed update_dataframe() - st.experimental_rerun() + st.rerun() # st.write(myobj) else: st.write("Failed") From 18274a4622160e9248e7ca906e5adbd1609913d7 Mon Sep 17 00:00:00 2001 From: "AARETE\\agupta" Date: Fri, 21 Jun 2024 16:25:20 -0500 Subject: [PATCH 3/3] UI 1 Fix --- streamlit/interface_1.py | 67 +++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 32 deletions(-) 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)