James McCool
commited on
Commit
·
46c890f
1
Parent(s):
3cdab9b
Refactor portfolio loading status management to use session state. This change ensures consistent tracking of the portfolio loading status across different upload sources, enhancing the overall data loading functionality.
Browse files
app.py
CHANGED
|
@@ -560,13 +560,13 @@ if selected_tab == 'Data Load':
|
|
| 560 |
st.info("Go ahead and upload a portfolio file here. Only include player columns.")
|
| 561 |
|
| 562 |
upload_toggle = st.selectbox("What source are you uploading from?", options=['Paydirt DB', 'SaberSim (Just IDs)', 'Draftkings/Fanduel (Names + IDs)', 'Other (Just Names)'])
|
| 563 |
-
portfolio_loaded = False
|
| 564 |
if upload_toggle == 'Paydirt DB':
|
| 565 |
if st.button("Load from Database after inserting site CSV"):
|
| 566 |
if site_var == 'Draftkings':
|
| 567 |
portfolio_load = init_DK_NFL_lineups(type_var, 'Main', 'proj', 50, dk_nfl_showdown_db_translation, 1000, [])
|
| 568 |
portfolio_file = pd.DataFrame(portfolio_load)
|
| 569 |
-
portfolio_loaded = True
|
| 570 |
if 'portfolio' in st.session_state:
|
| 571 |
del st.session_state['portfolio']
|
| 572 |
if 'export_portfolio' in st.session_state:
|
|
@@ -574,7 +574,7 @@ if selected_tab == 'Data Load':
|
|
| 574 |
else:
|
| 575 |
portfolio_load = init_FD_NFL_lineups(type_var, 'Main', 'proj', 50, fd_nfl_showdown_db_translation, 1000, [])
|
| 576 |
portfolio_file = pd.DataFrame(portfolio_load)
|
| 577 |
-
portfolio_loaded = True
|
| 578 |
if 'portfolio' in st.session_state:
|
| 579 |
del st.session_state['portfolio']
|
| 580 |
if 'export_portfolio' in st.session_state:
|
|
@@ -582,7 +582,7 @@ if selected_tab == 'Data Load':
|
|
| 582 |
|
| 583 |
elif upload_toggle == 'SaberSim (Just IDs)' or upload_toggle == 'Draftkings/Fanduel (Names + IDs)':
|
| 584 |
portfolio_file = st.file_uploader("Upload Portfolio File (CSV or Excel)", type=['csv', 'xlsx', 'xls'])
|
| 585 |
-
portfolio_loaded = True
|
| 586 |
if 'portfolio' in st.session_state:
|
| 587 |
del st.session_state['portfolio']
|
| 588 |
if 'export_portfolio' in st.session_state:
|
|
@@ -590,14 +590,14 @@ if selected_tab == 'Data Load':
|
|
| 590 |
|
| 591 |
else:
|
| 592 |
portfolio_file = st.file_uploader("Upload Portfolio File (CSV or Excel)", type=['csv', 'xlsx', 'xls'])
|
| 593 |
-
portfolio_loaded = True
|
| 594 |
if 'portfolio' in st.session_state:
|
| 595 |
del st.session_state['portfolio']
|
| 596 |
if 'export_portfolio' in st.session_state:
|
| 597 |
del st.session_state['export_portfolio']
|
| 598 |
|
| 599 |
if 'portfolio' not in st.session_state:
|
| 600 |
-
if portfolio_loaded:
|
| 601 |
if upload_toggle == 'Paydirt DB':
|
| 602 |
st.session_state['export_portfolio'] = portfolio_file
|
| 603 |
st.session_state['portfolio'] = portfolio_file
|
|
@@ -707,7 +707,7 @@ if selected_tab == 'Data Load':
|
|
| 707 |
|
| 708 |
st.dataframe(projections.head(10))
|
| 709 |
|
| 710 |
-
if
|
| 711 |
if st.session_state['portfolio'] is not None and projections is not None:
|
| 712 |
|
| 713 |
st.subheader("Name Matching Analysis")
|
|
|
|
| 560 |
st.info("Go ahead and upload a portfolio file here. Only include player columns.")
|
| 561 |
|
| 562 |
upload_toggle = st.selectbox("What source are you uploading from?", options=['Paydirt DB', 'SaberSim (Just IDs)', 'Draftkings/Fanduel (Names + IDs)', 'Other (Just Names)'])
|
| 563 |
+
st.session_state['portfolio_loaded'] = False
|
| 564 |
if upload_toggle == 'Paydirt DB':
|
| 565 |
if st.button("Load from Database after inserting site CSV"):
|
| 566 |
if site_var == 'Draftkings':
|
| 567 |
portfolio_load = init_DK_NFL_lineups(type_var, 'Main', 'proj', 50, dk_nfl_showdown_db_translation, 1000, [])
|
| 568 |
portfolio_file = pd.DataFrame(portfolio_load)
|
| 569 |
+
st.session_state['portfolio_loaded'] = True
|
| 570 |
if 'portfolio' in st.session_state:
|
| 571 |
del st.session_state['portfolio']
|
| 572 |
if 'export_portfolio' in st.session_state:
|
|
|
|
| 574 |
else:
|
| 575 |
portfolio_load = init_FD_NFL_lineups(type_var, 'Main', 'proj', 50, fd_nfl_showdown_db_translation, 1000, [])
|
| 576 |
portfolio_file = pd.DataFrame(portfolio_load)
|
| 577 |
+
st.session_state['portfolio_loaded'] = True
|
| 578 |
if 'portfolio' in st.session_state:
|
| 579 |
del st.session_state['portfolio']
|
| 580 |
if 'export_portfolio' in st.session_state:
|
|
|
|
| 582 |
|
| 583 |
elif upload_toggle == 'SaberSim (Just IDs)' or upload_toggle == 'Draftkings/Fanduel (Names + IDs)':
|
| 584 |
portfolio_file = st.file_uploader("Upload Portfolio File (CSV or Excel)", type=['csv', 'xlsx', 'xls'])
|
| 585 |
+
st.session_state['portfolio_loaded'] = True
|
| 586 |
if 'portfolio' in st.session_state:
|
| 587 |
del st.session_state['portfolio']
|
| 588 |
if 'export_portfolio' in st.session_state:
|
|
|
|
| 590 |
|
| 591 |
else:
|
| 592 |
portfolio_file = st.file_uploader("Upload Portfolio File (CSV or Excel)", type=['csv', 'xlsx', 'xls'])
|
| 593 |
+
st.session_state['portfolio_loaded'] = True
|
| 594 |
if 'portfolio' in st.session_state:
|
| 595 |
del st.session_state['portfolio']
|
| 596 |
if 'export_portfolio' in st.session_state:
|
| 597 |
del st.session_state['export_portfolio']
|
| 598 |
|
| 599 |
if 'portfolio' not in st.session_state:
|
| 600 |
+
if st.session_state['portfolio_loaded']:
|
| 601 |
if upload_toggle == 'Paydirt DB':
|
| 602 |
st.session_state['export_portfolio'] = portfolio_file
|
| 603 |
st.session_state['portfolio'] = portfolio_file
|
|
|
|
| 707 |
|
| 708 |
st.dataframe(projections.head(10))
|
| 709 |
|
| 710 |
+
if st.session_state['portfolio_loaded'] and projections_file:
|
| 711 |
if st.session_state['portfolio'] is not None and projections is not None:
|
| 712 |
|
| 713 |
st.subheader("Name Matching Analysis")
|