diff --git a/streamlit/interface_0.py b/streamlit/interface_0.py index 414f02b..0e37a1f 100644 --- a/streamlit/interface_0.py +++ b/streamlit/interface_0.py @@ -78,17 +78,17 @@ try: util.setup_page(REDIRECT_URI) except Exception as e: st.write(f"SSO Failed = {e}") - 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 Line after development. try: c1.write(f"User: **{st.session_state.user_info['displayName']}**") user_mail = st.session_state.user_info['mail'] -except KeyError as e: +except KeyError as e: # RECOMMENDATION - Not Working as Expected. Unreachable Code because the above Exception handles everything st.write("Session Expired.") auth_url = security.get_auth_url(REDIRECT_URI) st.markdown(f"Sign In", unsafe_allow_html=True) st.stop() -s3_client = boto3.client('s3', +s3_client = boto3.client('s3', # RECOMMENDATION - We can make use of AWS Access Key for enabling this in local testing. Will help a lot. region_name="us-east-2", ) @@ -190,7 +190,7 @@ with buttons[1]: st.session_state.landing_zone = 'contracts-landing-zone' - + # RECOMMENDATION - Rethink about how to best manage cache # @st.cache_data # def convert_df(df): # return df.to_csv(index=False).encode('utf-8') diff --git a/streamlit/interface_1.py b/streamlit/interface_1.py index c38b7be..2e297c8 100644 --- a/streamlit/interface_1.py +++ b/streamlit/interface_1.py @@ -49,7 +49,7 @@ try: util.setup_page(REDIRECT_URI) 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'] diff --git a/streamlit/interface_2.py b/streamlit/interface_2.py index e434842..e11ceec 100644 --- a/streamlit/interface_2.py +++ b/streamlit/interface_2.py @@ -28,6 +28,7 @@ from util import logger (REDIRECT_URI, create_batch_url, doczy_pipeline) = util.load_page_details(2) user_list = USER_LIST + st.set_page_config(layout = "wide") # Sidebar contents with st.sidebar: @@ -57,10 +58,10 @@ st.markdown(hide_img_fs, unsafe_allow_html=True) _,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'] @@ -79,11 +80,11 @@ except: 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) @@ -147,49 +148,52 @@ if client: with field_row[0]: st.write("**Field Group**") with field_row[1]: - field_group = st.selectbox('Field Group',('Unique Key', 'Pricing Before Carveouts', 'Contract Related'), - label_visibility = "collapsed", index = None) - # field_group = st.selectbox('Field Group',('Unique Key', 'Contract Related', 'Pricing Before Carveouts - I' - # , '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", index = None) + 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': - # fields = fields[fields['PRIORITY'] == 'A'] - # elif field_group == 'Contract Related': - # fields = fields[fields['PRIORITY'] == 'C'] - # elif field_group == 'Pricing Before Carveouts - I': - # fields = fields[fields['PRIORITY'] == 'B'] - # fields = np.array_split(fields, 2)[0] - # elif field_group == 'Pricing Before Carveouts - II': - # fields = fields[fields['PRIORITY'] == 'B'] - # fields = np.array_split(fields, 2)[1] - # elif field_group == 'Carveout Indicator, Code Type and Code #s - I': - # fields = fields[fields['PRIORITY'] == 'F'] - # fields = np.array_split(fields, 3)[0] - # elif field_group == 'Carveout Indicator, Code Type and Code #s - II': - # fields = fields[fields['PRIORITY'] == 'F'] - # fields = np.array_split(fields, 3)[1] - # elif field_group == 'Carveout Indicator, Code Type and Code #s - III': - # fields = fields[fields['PRIORITY'] == 'F'] - # fields = np.array_split(fields, 3)[2] - # elif field_group == 'Carveout Methodology - I': - # fields = fields[fields['PRIORITY'] == 'G'] - # fields = np.array_split(fields, 4)[0] - # elif field_group == 'Carveout Methodology - II': - # fields = fields[fields['PRIORITY'] == 'G'] - # fields = np.array_split(fields, 4)[1] - # elif field_group == 'Carveout Method - III': - # fields = fields[fields['PRIORITY'] == 'G'] - # fields = np.array_split(fields, 4)[2] - # elif field_group == 'Carveout Method - IV': - # fields = fields[fields['PRIORITY'] == 'G'] - # fields = np.array_split(fields, 4)[3] - # elif field_group == 'Provider': - # fields = fields[fields['PRIORITY'] == 'D'] - # elif field_group == 'Timeline': - # fields = fields[fields['PRIORITY'] == 'E'] + 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'] + elif field_group == 'Pricing Before Carveouts - I': + fields = fields[fields['PRIORITY'] == 'B'] + fields = np.array_split(fields, 2)[0] + elif field_group == 'Pricing Before Carveouts - II': + fields = fields[fields['PRIORITY'] == 'B'] + fields = np.array_split(fields, 2)[1] + elif field_group == 'Carveout Indicator, Code Type and Code #s - I': + fields = fields[fields['PRIORITY'] == 'F'] + fields = np.array_split(fields, 3)[0] + elif field_group == 'Carveout Indicator, Code Type and Code #s - II': + fields = fields[fields['PRIORITY'] == 'F'] + fields = np.array_split(fields, 3)[1] + elif field_group == 'Carveout Indicator, Code Type and Code #s - III': + fields = fields[fields['PRIORITY'] == 'F'] + fields = np.array_split(fields, 3)[2] + elif field_group == 'Carveout Methodology - I': + fields = fields[fields['PRIORITY'] == 'G'] + fields = np.array_split(fields, 4)[0] + elif field_group == 'Carveout Methodology - II': + fields = fields[fields['PRIORITY'] == 'G'] + fields = np.array_split(fields, 4)[1] + elif field_group == 'Carveout Method - III': + fields = fields[fields['PRIORITY'] == 'G'] + fields = np.array_split(fields, 4)[2] + elif field_group == 'Carveout Method - IV': + fields = fields[fields['PRIORITY'] == 'G'] + fields = np.array_split(fields, 4)[3] + elif field_group == 'Provider': + fields = fields[fields['PRIORITY'] == 'D'] + elif field_group == 'Timeline': + fields = fields[fields['PRIORITY'] == 'E'] + + if st.button("Show Results"): + 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]) button_cols = st.columns([1,2,6]) with button_cols[0]: