James McCool
commited on
Commit
·
e7260ac
1
Parent(s):
4586856
Refactor contest file handling in app.py to improve session state management
Browse files- Updated the handling of the contest file upload to store the file in session state, ensuring consistent access across different conditions.
- Adjusted the logic for loading contest data to check session state for 'Contest_file', enhancing data integrity and user experience during manual and database search processes.
app.py
CHANGED
|
@@ -68,12 +68,12 @@ with tab1:
|
|
| 68 |
if parse_type == 'DB Search':
|
| 69 |
contest_name_var = st.selectbox("Select Contest to load", contest_names)
|
| 70 |
elif parse_type == 'Manual':
|
| 71 |
-
Contest_file = st.file_uploader("Upload Contest File (CSV or Excel)", type=['csv', 'xlsx', 'xls'])
|
| 72 |
if 'Contest' in st.session_state:
|
| 73 |
del st.session_state['Contest']
|
| 74 |
if parse_type == 'Manual':
|
| 75 |
-
if Contest_file and 'Adj_Contest' not in st.session_state:
|
| 76 |
-
st.session_state['Contest'], st.session_state['ownership_df'], st.session_state['actual_df'], st.session_state['entry_list'] = load_contest_file(Contest_file, sport_select)
|
| 77 |
st.session_state['Contest'] = st.session_state['Contest'].dropna(how='all')
|
| 78 |
st.session_state['Contest'] = st.session_state['Contest'].reset_index(drop=True)
|
| 79 |
if st.session_state['Contest'] is not None:
|
|
@@ -81,9 +81,9 @@ with tab1:
|
|
| 81 |
st.dataframe(st.session_state['Contest'].head(10))
|
| 82 |
elif parse_type == 'DB Search':
|
| 83 |
if st.button('Load Contest Data', key='load_contest_data'):
|
| 84 |
-
Contest_file = grab_contest_data('MLB', contest_name_var, contest_id_map, contest_date_map)
|
| 85 |
if 'Adj_Contest' not in st.session_state:
|
| 86 |
-
st.session_state['Contest'], st.session_state['ownership_df'], st.session_state['actual_df'], st.session_state['entry_list'] = load_contest_file(Contest_file, sport_select)
|
| 87 |
st.session_state['Contest'] = st.session_state['Contest'].dropna(how='all')
|
| 88 |
st.session_state['Contest'] = st.session_state['Contest'].reset_index(drop=True)
|
| 89 |
if st.session_state['Contest'] is not None:
|
|
|
|
| 68 |
if parse_type == 'DB Search':
|
| 69 |
contest_name_var = st.selectbox("Select Contest to load", contest_names)
|
| 70 |
elif parse_type == 'Manual':
|
| 71 |
+
st.session_state['Contest_file'] = st.file_uploader("Upload Contest File (CSV or Excel)", type=['csv', 'xlsx', 'xls'])
|
| 72 |
if 'Contest' in st.session_state:
|
| 73 |
del st.session_state['Contest']
|
| 74 |
if parse_type == 'Manual':
|
| 75 |
+
if 'Contest_file' not in st.session_state and 'Adj_Contest' not in st.session_state:
|
| 76 |
+
st.session_state['Contest'], st.session_state['ownership_df'], st.session_state['actual_df'], st.session_state['entry_list'] = load_contest_file(st.session_state['Contest_file'], sport_select)
|
| 77 |
st.session_state['Contest'] = st.session_state['Contest'].dropna(how='all')
|
| 78 |
st.session_state['Contest'] = st.session_state['Contest'].reset_index(drop=True)
|
| 79 |
if st.session_state['Contest'] is not None:
|
|
|
|
| 81 |
st.dataframe(st.session_state['Contest'].head(10))
|
| 82 |
elif parse_type == 'DB Search':
|
| 83 |
if st.button('Load Contest Data', key='load_contest_data'):
|
| 84 |
+
st.session_state['Contest_file'] = grab_contest_data('MLB', contest_name_var, contest_id_map, contest_date_map)
|
| 85 |
if 'Adj_Contest' not in st.session_state:
|
| 86 |
+
st.session_state['Contest'], st.session_state['ownership_df'], st.session_state['actual_df'], st.session_state['entry_list'] = load_contest_file(st.session_state['Contest_file'], sport_select)
|
| 87 |
st.session_state['Contest'] = st.session_state['Contest'].dropna(how='all')
|
| 88 |
st.session_state['Contest'] = st.session_state['Contest'].reset_index(drop=True)
|
| 89 |
if st.session_state['Contest'] is not None:
|