Merged in feature/streamlit_multipageApp (pull request #138)

Feature/streamlit multipageApp

Approved-by: Umang Mistry
This commit is contained in:
Pratham Soni
2024-06-24 15:48:02 +00:00
committed by Umang Mistry
2 changed files with 12 additions and 17 deletions
+1 -13
View File
@@ -16,11 +16,6 @@ from util import logger
(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
@@ -97,10 +92,7 @@ if client:
batch_list = []
for prefix in batch_objects['CommonPrefixes']:
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])
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',
@@ -263,7 +255,6 @@ if client:
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)
@@ -280,9 +271,6 @@ if client:
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")
+11 -4
View File
@@ -2,6 +2,7 @@ import streamlit as st
import msal
import requests
import boto3
import secrets
from botocore.exceptions import ClientError
import json
@@ -57,7 +58,11 @@ app = msal.ConfidentialClientApplication(CLIENT_ID, authority=AUTHORITY, client_
def get_auth_url(REDIRECT_URI):
auth_url = app.get_authorization_request_url(SCOPE, redirect_uri=REDIRECT_URI )
#Generates a random stat parameter
state = secrets.token_urlsafe(16)
#Stores the state param in the session state
st.session_state['state'] = state
auth_url = app.get_authorization_request_url(SCOPE, redirect_uri=REDIRECT_URI, state=state)
return auth_url
@st.cache_data
@@ -75,11 +80,13 @@ def get_user_info(access_token):
def handle_redirect(REDIRECT_URI):
if not st.session_state.get('access_token'):
query_params = st.experimental_get_query_params()
code = st.query_params.get('code')
if code:
access_token = get_token_from_code(code, REDIRECT_URI)
state=query_params.get('state')
if code and state and state[0] == st.session_state.get('state'):
access_token = get_token_from_code(code[0], REDIRECT_URI)
st.session_state['access_token'] = access_token
st.session_state
clear_url()