diff --git a/streamlit/interface_0.py b/streamlit/interface_0.py index f638209..e0c0e63 100644 --- a/streamlit/interface_0.py +++ b/streamlit/interface_0.py @@ -14,10 +14,10 @@ from io import StringIO, BytesIO from sf_conn import get_client_names, insert_upload_logs from constants import USER_LIST -create_batch_url = 'https://lfksus2t62.execute-api.us-east-2.amazonaws.com/dev/create-batch' +create_batch_url = 'https://lfksus2t62.execute-api.us-east-2.amazonaws.com/dev/create-batch' # RECOMMENDATION - Store in Constants or AWS Secrets Manager -REDIRECT_URI = 'https://doczydev.aarete.com:8500' -user_list = USER_LIST +REDIRECT_URI = 'https://doczydev.aarete.com:8500' +user_list = USER_LIST # RECOMMENDATION - Unsafe in Constants as well, should be fetched from Snowflake st.set_page_config(layout = "wide") # # Sidebar contents # with st.sidebar: @@ -37,17 +37,16 @@ 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'} -try: + st.session_state['user_info'] = {'mail': 'maamseek@aarete.com', 'displayName': 'Mayank Aamseek'} # RECOMMENDATION - Remove Line after development. 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.") 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", ) @@ -84,7 +83,7 @@ df['Contract Name'] = file_list file_names = [] buttons = st.columns([0.4, 0.4, 0.2]) with buttons[1]: - if st.button("Create Batch"): + if st.button("Create Batch"): # RECOMMENDATION - Use on-click to handle everything below this. Better in terms of re-running code. myobj = { "client-bucket-name": client_bucket } response = requests.post(create_batch_url, json = myobj) @@ -113,7 +112,7 @@ with buttons[1]: st.write(f"{batch_id} created") st.write(f"Files uploaded to s3://{client_bucket}/{landing_zone}{batch_id}") - + # RECOMMENDATION - Rethink about how to best manage cache # @st.cache_data # def convert_df(df): # return df.to_csv(index=False).encode('utf-8')