James McCool commited on
Commit
e40b70b
·
1 Parent(s): 041e021

Update app.py to modify the init_DK_lineups and init_FD_lineups functions by adding a slate_var parameter, enhancing flexibility in lineup initialization. Refactor the "Load/Reset Data" button implementation to improve code organization and maintainability within the main container.

Browse files
Files changed (1) hide show
  1. app.py +14 -10
app.py CHANGED
@@ -82,7 +82,7 @@ def init_baselines():
82
  return roo_data, sd_roo_data, scoring_percentages
83
 
84
  @st.cache_data(ttl = 60)
85
- def init_DK_lineups():
86
 
87
  collection = db2['DK_MLB_SD1_seed_frame']
88
  cursor = collection.find().limit(10000)
@@ -94,7 +94,7 @@ def init_DK_lineups():
94
  return DK_seed
95
 
96
  @st.cache_data(ttl = 60)
97
- def init_FD_lineups():
98
 
99
  collection = db2['FD_MLB_SD1_seed_frame']
100
  cursor = collection.find().limit(10000)
@@ -121,14 +121,18 @@ with st.container():
121
  with col2:
122
  site_var = st.selectbox("What site do you want to view?", ('Draftkings', 'Fanduel'), key='site_var')
123
  with col3:
124
- if st.button("Load/Reset Data", key='reset'):
125
- st.cache_data.clear()
126
- roo_data, sd_roo_data, scoring_percentages = init_baselines()
127
- hold_display = roo_data
128
- dk_lineups = init_DK_lineups('Main')
129
- fd_lineups = init_FD_lineups('Main')
130
- for key in st.session_state.keys():
131
- del st.session_state[key]
 
 
 
 
132
 
133
  tab1, tab2, tab3 = st.tabs(["Scoring Percentages", "Player ROO", "Optimals"])
134
 
 
82
  return roo_data, sd_roo_data, scoring_percentages
83
 
84
  @st.cache_data(ttl = 60)
85
+ def init_DK_lineups(slate_var):
86
 
87
  collection = db2['DK_MLB_SD1_seed_frame']
88
  cursor = collection.find().limit(10000)
 
94
  return DK_seed
95
 
96
  @st.cache_data(ttl = 60)
97
+ def init_FD_lineups(slate_var):
98
 
99
  collection = db2['FD_MLB_SD1_seed_frame']
100
  cursor = collection.find().limit(10000)
 
121
  with col2:
122
  site_var = st.selectbox("What site do you want to view?", ('Draftkings', 'Fanduel'), key='site_var')
123
  with col3:
124
+ container = st.container()
125
+ with container:
126
+ col = st.columns(3)[1] # Create 3 columns and use middle one
127
+ with col:
128
+ if st.button("Load/Reset Data", key='reset'):
129
+ st.cache_data.clear()
130
+ roo_data, sd_roo_data, scoring_percentages = init_baselines()
131
+ hold_display = roo_data
132
+ dk_lineups = init_DK_lineups('Main')
133
+ fd_lineups = init_FD_lineups('Main')
134
+ for key in st.session_state.keys():
135
+ del st.session_state[key]
136
 
137
  tab1, tab2, tab3 = st.tabs(["Scoring Percentages", "Player ROO", "Optimals"])
138