For UI 2 - Wrote comments that identify hardcodings and provide recommendations on a potential better approach.
This commit is contained in:
+10
-10
@@ -21,7 +21,7 @@ import re
|
||||
from sf_conn import get_snowflake_conn
|
||||
|
||||
REDIRECT_URI = 'https://doczydev.aarete.com:8502'
|
||||
user_list = USER_LIST
|
||||
user_list = USER_LIST # RECOMMENDATION - AWS Secrets Manager or Snowflake
|
||||
|
||||
st.set_page_config(layout = "wide")
|
||||
# Sidebar contents
|
||||
@@ -39,10 +39,10 @@ with st.sidebar:
|
||||
|
||||
_,c1= st.columns([5,1])
|
||||
try:
|
||||
util.setup_page(REDIRECT_URI)
|
||||
util.setup_page(REDIRECT_URI) # RECOMMENDATION - Not secure enough
|
||||
except:
|
||||
st.write("SSO Failed")
|
||||
st.session_state['user_info'] = {'mail': 'maamseek@aarete.com', 'displayName': 'Mayank Aamseek'}
|
||||
st.session_state['user_info'] = {'mail': 'maamseek@aarete.com', 'displayName': 'Mayank Aamseek'} # RECOMMENDATION - Remove after dev phase
|
||||
try:
|
||||
c1.write(f"User: **{st.session_state.user_info['displayName']}**")
|
||||
user_mail = st.session_state.user_info['mail']
|
||||
@@ -54,21 +54,21 @@ except KeyError as e:
|
||||
try:
|
||||
conn = get_snowflake_conn('STG')
|
||||
cur = conn.cursor()
|
||||
query = 'select * from "TRAINING_DATA_RAW"'
|
||||
query = 'select * from "TRAINING_DATA_RAW"' # RECOMMENDATION - Move all queries to another file like constants
|
||||
cur.execute(query)
|
||||
field_values = pd.DataFrame.from_records(iter(cur), columns=[x[0] for x in cur.description])
|
||||
field_values['Document_Name'] = field_values['DOCUMENT_NAME']
|
||||
field_values['Document_Name'] = field_values['DOCUMENT_NAME'] # RECOMMENDATION - Use String Matching or something less hardcoded
|
||||
except:
|
||||
# field_values = pd.read_csv('contract_field_values.csv', encoding='unicode_escape', skipinitialspace=True)
|
||||
# field_values = field_values.loc[:, ~field_values.columns.str.contains('Unnamed:')]
|
||||
st.write("Conn failed, unable to fetch data from training data table in Snowflake")
|
||||
|
||||
try:
|
||||
query = 'select * from "PROMPT_CONFIG"'
|
||||
query = 'select * from "PROMPT_CONFIG"' # RECOMMENDATION - Move query somewhere else
|
||||
cur.execute(query)
|
||||
fields = pd.DataFrame.from_records(iter(cur), columns=[x[0] for x in cur.description])
|
||||
|
||||
fields.rename(columns={'FIELD_DESC': 'Field Name'}, inplace = True)
|
||||
fields.rename(columns={'FIELD_DESC': 'Field Name'}, inplace = True) # RECOMMENDATION - Package into less hardcoded function or handle in DB
|
||||
fields.rename(columns={'PROMPT': 'Interrogation Question?'}, inplace = True)
|
||||
fields.rename(columns={'GROUP_ID': 'PRIORITY'}, inplace = True)
|
||||
fields.rename(columns={'FIELD_NAME': 'SF_DB_COL_NAME'}, inplace = True)
|
||||
@@ -103,13 +103,13 @@ field_row = st.columns([0.2, 0.7, 0.1])
|
||||
with field_row[0]:
|
||||
st.write("**Field Group**")
|
||||
with field_row[1]:
|
||||
field_group = st.selectbox('Field Group',('Unique Key', 'Contract Related', 'Pricing Before Carveouts - I'
|
||||
field_group = st.selectbox('Field Group',('Unique Key', 'Contract Related', 'Pricing Before Carveouts - I' # RECOMMENDATION - Get from a separate list or snowflake
|
||||
, 'Pricing Before Carveouts - II', 'Carveout Indicator, Code Type and Code #s - I'
|
||||
, 'Carveout Indicator, Code Type and Code #s - II', 'Carveout Indicator, Code Type and Code #s - III'
|
||||
, 'Optimize Carving Indic.', 'Carveout Method - I', 'Carveout Method - II', 'Provider'
|
||||
, 'Timeline'), label_visibility = "collapsed")
|
||||
|
||||
if field_group == 'Unique Key':
|
||||
if field_group == 'Unique Key': # RECOMMENDATION - Use a Dictionary for this mapping
|
||||
fields = fields[fields['PRIORITY'] == 'A']
|
||||
elif field_group == 'Contract Related':
|
||||
fields = fields[fields['PRIORITY'] == 'C']
|
||||
@@ -146,7 +146,7 @@ elif field_group == 'Timeline':
|
||||
fields = fields[fields['PRIORITY'] == 'E']
|
||||
|
||||
if st.button("Show Results"):
|
||||
query = 'select * from "DOCZY_PIPELINE_RAW_OUTPUT"'
|
||||
query = 'select * from "DOCZY_PIPELINE_RAW_OUTPUT"' # RECOMMENDATION - Move query somewhere else
|
||||
cur.execute(query)
|
||||
df2 = pd.DataFrame.from_records(iter(cur), columns=[x[0] for x in cur.description])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user