James McCool
commited on
Commit
·
8866c0e
1
Parent(s):
1c30ca9
Enhance projections loading logic in Data Load tab
Browse filesUpdated the session state management for projections loading. Introduced a check to initialize the 'projections_loaded' state and modified the condition for loading projections to ensure it only occurs when projections have been successfully uploaded or loaded from the database. This improves the reliability of the loading process and enhances user feedback.
app.py
CHANGED
|
@@ -660,12 +660,16 @@ if selected_tab == 'Data Load':
|
|
| 660 |
upload_col, template_col = st.columns([3, 1])
|
| 661 |
|
| 662 |
with upload_col:
|
|
|
|
|
|
|
| 663 |
if proj_options == 'User Upload':
|
| 664 |
projections_file = st.file_uploader("Upload Projections File (CSV or Excel)", type=['csv', 'xlsx', 'xls'])
|
|
|
|
| 665 |
elif proj_options == 'Paydirt DB':
|
| 666 |
if st.button("Load from Database"):
|
| 667 |
projections_file = init_nfl_baselines(type_var, site_var, 'Main Slate')[0]
|
| 668 |
st.session_state['db_projections_file'] = projections_file
|
|
|
|
| 669 |
if 'projections_df' in st.session_state:
|
| 670 |
del st.session_state['projections_df']
|
| 671 |
|
|
@@ -680,7 +684,7 @@ if selected_tab == 'Data Load':
|
|
| 680 |
mime="text/csv"
|
| 681 |
)
|
| 682 |
|
| 683 |
-
if
|
| 684 |
export_projections, projections = load_file(projections_file, site_var, type_var, sport_var, 'projections')
|
| 685 |
if projections is not None:
|
| 686 |
st.success('Projections file loaded successfully!')
|
|
|
|
| 660 |
upload_col, template_col = st.columns([3, 1])
|
| 661 |
|
| 662 |
with upload_col:
|
| 663 |
+
if 'portfolio' not in st.session_state:
|
| 664 |
+
st.session_state['projections_loaded'] = False
|
| 665 |
if proj_options == 'User Upload':
|
| 666 |
projections_file = st.file_uploader("Upload Projections File (CSV or Excel)", type=['csv', 'xlsx', 'xls'])
|
| 667 |
+
st.session_state['projections_loaded'] = True
|
| 668 |
elif proj_options == 'Paydirt DB':
|
| 669 |
if st.button("Load from Database"):
|
| 670 |
projections_file = init_nfl_baselines(type_var, site_var, 'Main Slate')[0]
|
| 671 |
st.session_state['db_projections_file'] = projections_file
|
| 672 |
+
st.session_state['projections_loaded'] = True
|
| 673 |
if 'projections_df' in st.session_state:
|
| 674 |
del st.session_state['projections_df']
|
| 675 |
|
|
|
|
| 684 |
mime="text/csv"
|
| 685 |
)
|
| 686 |
|
| 687 |
+
if st.session_state['projections_loaded']:
|
| 688 |
export_projections, projections = load_file(projections_file, site_var, type_var, sport_var, 'projections')
|
| 689 |
if projections is not None:
|
| 690 |
st.success('Projections file loaded successfully!')
|