James McCool
commited on
Commit
·
b84a1cd
1
Parent(s):
e7260ac
Refactor contest file handling in app.py for improved session state management
Browse files- Adjusted the logic for deleting 'Contest' from session state to ensure it only occurs when necessary, enhancing clarity and maintainability.
- Updated the condition for executing name matching functions to check for the presence of 'Contest_file' and 'projections_df', improving data integrity and user experience.
app.py
CHANGED
@@ -69,8 +69,8 @@ with tab1:
|
|
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 |
-
|
73 |
-
|
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)
|
@@ -119,7 +119,7 @@ with tab1:
|
|
119 |
st.success('Projections file loaded successfully!')
|
120 |
st.dataframe(st.session_state['projections_df'].head(10))
|
121 |
|
122 |
-
if
|
123 |
st.subheader("Name Matching functions")
|
124 |
if 'Adj_Contest' not in st.session_state:
|
125 |
try:
|
|
|
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)
|
|
|
119 |
st.success('Projections file loaded successfully!')
|
120 |
st.dataframe(st.session_state['projections_df'].head(10))
|
121 |
|
122 |
+
if 'Contest_file' in st.session_state and 'projections_df' in st.session_state:
|
123 |
st.subheader("Name Matching functions")
|
124 |
if 'Adj_Contest' not in st.session_state:
|
125 |
try:
|