James McCool
commited on
Commit
·
cac37db
1
Parent(s):
cf90438
Enhance error handling for payout information retrieval in app.py
Browse files- Updated the payout information retrieval process to include try-except blocks, ensuring that the application handles potential errors gracefully and sets payout_info to None if retrieval fails.
- This change improves the robustness of the data loading functionality, maintaining application stability during data processing.
app.py
CHANGED
|
@@ -106,8 +106,8 @@ def export_contest_file(db, sport, type, contest_date, contest_id, contest_data)
|
|
| 106 |
def get_payout_for_position(finish_pos, payout_df):
|
| 107 |
# Find the row where finish_pos falls between minPosition and maxPosition
|
| 108 |
matching_row = payout_df[
|
| 109 |
-
(payout_df['minPosition'] <= finish_pos) &
|
| 110 |
-
(payout_df['maxPosition'] >= finish_pos)
|
| 111 |
]
|
| 112 |
if not matching_row.empty:
|
| 113 |
return matching_row.iloc[0]['value']
|
|
@@ -238,8 +238,10 @@ if selected_tab == 'Data Load':
|
|
| 238 |
if st.button('Load Contest Data', key='load_contest_data'):
|
| 239 |
st.session_state['player_info'], st.session_state['info_maps'] = grab_contest_player_info(db, sport_init, type_init, date_select, contest_name_var, contest_id_map)
|
| 240 |
st.session_state['Contest_file'] = grab_contest_data(sport_init, contest_name_var, contest_id_map, date_select, date_select2)
|
| 241 |
-
|
| 242 |
-
|
|
|
|
|
|
|
| 243 |
else:
|
| 244 |
pass
|
| 245 |
with contest_upload:
|
|
@@ -256,8 +258,10 @@ if selected_tab == 'Data Load':
|
|
| 256 |
st.session_state['Contest_file'] = pd.read_csv(st.session_state['Contest_upload'])
|
| 257 |
except:
|
| 258 |
st.warning('Please upload a Contest CSV')
|
| 259 |
-
|
| 260 |
-
|
|
|
|
|
|
|
| 261 |
else:
|
| 262 |
pass
|
| 263 |
|
|
|
|
| 106 |
def get_payout_for_position(finish_pos, payout_df):
|
| 107 |
# Find the row where finish_pos falls between minPosition and maxPosition
|
| 108 |
matching_row = payout_df[
|
| 109 |
+
(payout_df['minPosition'] <= finish_pos - 1) &
|
| 110 |
+
(payout_df['maxPosition'] >= finish_pos - 1)
|
| 111 |
]
|
| 112 |
if not matching_row.empty:
|
| 113 |
return matching_row.iloc[0]['value']
|
|
|
|
| 238 |
if st.button('Load Contest Data', key='load_contest_data'):
|
| 239 |
st.session_state['player_info'], st.session_state['info_maps'] = grab_contest_player_info(db, sport_init, type_init, date_select, contest_name_var, contest_id_map)
|
| 240 |
st.session_state['Contest_file'] = grab_contest_data(sport_init, contest_name_var, contest_id_map, date_select, date_select2)
|
| 241 |
+
try:
|
| 242 |
+
st.session_state['payout_info'] = grab_contest_payout_info(db, sport_init, type_init, date_select, contest_name_var, contest_id_map)
|
| 243 |
+
except:
|
| 244 |
+
st.session_state['payout_info'] = None
|
| 245 |
else:
|
| 246 |
pass
|
| 247 |
with contest_upload:
|
|
|
|
| 258 |
st.session_state['Contest_file'] = pd.read_csv(st.session_state['Contest_upload'])
|
| 259 |
except:
|
| 260 |
st.warning('Please upload a Contest CSV')
|
| 261 |
+
try:
|
| 262 |
+
st.session_state['payout_info'] = grab_contest_payout_info(db, sport_init, type_init, date_select, contest_name_var, contest_id_map)
|
| 263 |
+
except:
|
| 264 |
+
st.session_state['payout_info'] = None
|
| 265 |
else:
|
| 266 |
pass
|
| 267 |
|