2024-02-28 18:05:03 +05:30
|
|
|
import streamlit as st
|
|
|
|
|
from streamlit_extras.add_vertical_space import add_vertical_space
|
|
|
|
|
import os
|
|
|
|
|
import streamlit as st
|
|
|
|
|
import pandas as pd
|
|
|
|
|
from io import StringIO
|
|
|
|
|
from datetime import datetime
|
2024-03-07 18:48:53 +05:30
|
|
|
import boto3
|
2024-03-08 17:36:36 +05:30
|
|
|
import util
|
2024-02-28 18:05:03 +05:30
|
|
|
|
2024-03-08 18:15:55 +05:30
|
|
|
REDIRECT_URI = 'http://172.29.20.126:8501'
|
2024-03-08 17:36:36 +05:30
|
|
|
user_list = ['maamseek@aarete.com', 'smahdavian@aarete.com', 'ahinge@aarete.com', 'akadam@aarete.com'
|
|
|
|
|
, 'piragavarapu@aarete.com', 'umistry@aarete.com']
|
2024-02-28 18:05:03 +05:30
|
|
|
st.set_page_config(layout = "wide")
|
|
|
|
|
# # Sidebar contents
|
|
|
|
|
# with st.sidebar:
|
|
|
|
|
# st.title("Doczy.AI ™")
|
|
|
|
|
# st.markdown(
|
|
|
|
|
# """
|
|
|
|
|
# ## About
|
|
|
|
|
# This app extracts data from contracts
|
|
|
|
|
|
|
|
|
|
# """
|
|
|
|
|
# )
|
|
|
|
|
# add_vertical_space(15)
|
|
|
|
|
# # st.write("Doczy")
|
|
|
|
|
|
2024-03-11 17:42:50 -05:00
|
|
|
|
2024-03-11 16:05:48 +05:30
|
|
|
util.setup_page(REDIRECT_URI)
|
|
|
|
|
if st.session_state.user_info['mail'] in user_list:
|
2024-03-08 17:36:36 +05:30
|
|
|
|
|
|
|
|
s3_client = boto3.client('s3',
|
|
|
|
|
region_name="us-east-1",
|
|
|
|
|
)
|
|
|
|
|
objects = s3_client.list_objects_v2(Bucket='doczy-dev-infra-textract'
|
|
|
|
|
, Prefix="batches/batch_1/", Delimiter='/')
|
|
|
|
|
|
|
|
|
|
folder_list = []
|
|
|
|
|
for prefix in objects['CommonPrefixes']:
|
|
|
|
|
folder_list.append(prefix['Prefix'][:-1].split('/')[-1])
|
|
|
|
|
|
|
|
|
|
client_row = st.columns([0.1, 0.8])
|
|
|
|
|
with client_row[0]:
|
|
|
|
|
st.write("**Client Name**")
|
|
|
|
|
with client_row[1]:
|
|
|
|
|
client = st.selectbox('Client Name',(folder_list), index=7, label_visibility = "collapsed")
|
|
|
|
|
|
|
|
|
|
folder_objects = s3_client.list_objects_v2(Bucket='doczy-dev-infra-textract'
|
|
|
|
|
, Prefix="batches/batch_1/"+client+"/", Delimiter='/')
|
|
|
|
|
|
|
|
|
|
folder_list_2 = []
|
|
|
|
|
for prefix in folder_objects['CommonPrefixes']:
|
|
|
|
|
folder_list_2.append(prefix['Prefix'][:-1].split('/')[-1])
|
|
|
|
|
|
|
|
|
|
path_row = st.columns([0.1, 0.8])
|
|
|
|
|
with path_row[0]:
|
|
|
|
|
st.write("**Path to folder**")
|
|
|
|
|
with path_row[1]:
|
|
|
|
|
Directory = st.selectbox('**Path to folder**', folder_list_2, label_visibility = "collapsed")
|
|
|
|
|
|
|
|
|
|
checks = st.columns([0.1, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12])
|
|
|
|
|
with checks[0]:
|
|
|
|
|
st.write("**Group No.**")
|
|
|
|
|
with checks[1]:
|
|
|
|
|
a = st.checkbox('Unique Key', key = str(1))
|
|
|
|
|
with checks[2]:
|
|
|
|
|
b = st.checkbox('Pricing Before Carveouts', key = str(2))
|
|
|
|
|
with checks[3]:
|
|
|
|
|
c = st.checkbox('Contract Related', key = str(3))
|
|
|
|
|
with checks[4]:
|
|
|
|
|
d = st.checkbox('Provider', key = str(4))
|
|
|
|
|
with checks[5]:
|
|
|
|
|
e = st.checkbox('Timeline', key = str(5))
|
|
|
|
|
with checks[6]:
|
|
|
|
|
f = st.checkbox('Carveout Indicator', key = str(6))
|
|
|
|
|
with checks[7]:
|
|
|
|
|
g = st.checkbox('Carveout Methodology', key = str(7))
|
|
|
|
|
|
|
|
|
|
add_vertical_space(1)
|
|
|
|
|
|
|
|
|
|
df = pd.DataFrame(columns=['Request ID','Contract ID','Contract Name','Unique Key','Pricing Before Carveouts'
|
|
|
|
|
, 'Contract Related', 'Provider', 'Timeline', 'Carveout Indicator', 'Carveout Methodology'])
|
|
|
|
|
file_list = []
|
|
|
|
|
file_objects = s3_client.list_objects_v2(Bucket='doczy-dev-infra-textract'
|
|
|
|
|
, Prefix="batches/batch_1/"+client+"/"+Directory+"/", Delimiter='/')
|
|
|
|
|
|
|
|
|
|
if st.button("Read the contracts from Path"):
|
|
|
|
|
for obj in file_objects.get('Contents',[]):
|
|
|
|
|
if not obj['Key'].endswith('/'):
|
|
|
|
|
file_list.append(obj['Key'].split('/')[-1])
|
|
|
|
|
|
|
|
|
|
df['Contract Name'] = file_list
|
|
|
|
|
df['Request ID'] = range(len(file_list))
|
|
|
|
|
df['Contract ID'] = file_list
|
|
|
|
|
df['Unique Key'] = a
|
|
|
|
|
df['Pricing Before Carveouts'] = b
|
|
|
|
|
df['Contract Related'] = c
|
|
|
|
|
df['Provider'] = d
|
|
|
|
|
df['Timeline'] = e
|
|
|
|
|
df['Carveout Indicator'] = f
|
|
|
|
|
df['Carveout Methodology'] = g
|
2024-03-10 07:54:31 +00:00
|
|
|
dir_path = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
|
print(f'DEBUGGING: PWD= {dir_path}')
|
2024-03-08 17:36:36 +05:30
|
|
|
df.to_csv('temp1.csv', index=False)
|
|
|
|
|
|
|
|
|
|
add_vertical_space(1)
|
|
|
|
|
|
|
|
|
|
# df_copy = df.set_index(df.columns[0]).copy()
|
|
|
|
|
df2 = pd.read_csv('temp1.csv')
|
|
|
|
|
edited_df = st.data_editor(df2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@st.cache_data
|
|
|
|
|
def convert_df(df):
|
|
|
|
|
return df.to_csv(index=False).encode('utf-8')
|
|
|
|
|
|
|
|
|
|
csv = convert_df(edited_df)
|
|
|
|
|
|
|
|
|
|
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]:
|
|
|
|
|
st.button("Run Doczy.AI Pipeline")
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
st.write("Access Denied")
|
2024-02-28 18:05:03 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
|