Spaces:
Running
Running
James McCool
commited on
Commit
·
e73b740
1
Parent(s):
be5801a
Add Data Updates tab in app.py for updating various data sources. Implemented functionality to select and update data sources (DFS, DVP, Air Yards, FAAB) via API, including session state management and user feedback for successful or failed updates.
Browse files
app.py
CHANGED
|
@@ -50,6 +50,7 @@ proj_source_options = ['Dwain', 'Freedman', 'Kickers', 'Defenses']
|
|
| 50 |
proj_replace_options = ['dwain', 'freedman', 'kickers', 'defenses']
|
| 51 |
ros_source_options = ['Laghezza', 'Ronis', 'Dwain', 'Freedman']
|
| 52 |
ros_replace_options = ['laghezza', 'ronis', 'dwain', 'freedman']
|
|
|
|
| 53 |
|
| 54 |
|
| 55 |
def grab_sr_fa(headers: dict) -> pd.DataFrame:
|
|
@@ -153,7 +154,7 @@ def grab_sr_ids(headers: dict) -> pd.DataFrame:
|
|
| 153 |
|
| 154 |
return pd.DataFrame(row_data, columns=['FA_ID', 'SR_ID', 'First_Name', 'Prefer_First_Name', 'Last_Name', 'Name_Suffix', 'Position', 'Team'])
|
| 155 |
|
| 156 |
-
tab1, tab2, tab3, tab4, tab5, tab6 = st.tabs(['Rankings Update', 'Projections Update', 'SR ID Update', 'Game Model Update', 'NCAAF Script', 'UR Push'])
|
| 157 |
|
| 158 |
with tab1:
|
| 159 |
with st.container():
|
|
@@ -812,5 +813,32 @@ with tab6:
|
|
| 812 |
st.write("Error updating current season")
|
| 813 |
st.write(response.json())
|
| 814 |
st.cache_data.clear()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 815 |
for key in st.session_state.keys():
|
| 816 |
del st.session_state[key]
|
|
|
|
| 50 |
proj_replace_options = ['dwain', 'freedman', 'kickers', 'defenses']
|
| 51 |
ros_source_options = ['Laghezza', 'Ronis', 'Dwain', 'Freedman']
|
| 52 |
ros_replace_options = ['laghezza', 'ronis', 'dwain', 'freedman']
|
| 53 |
+
data_update_options = ['DFS', 'DVP', 'Air Yards', 'FAAB']
|
| 54 |
|
| 55 |
|
| 56 |
def grab_sr_fa(headers: dict) -> pd.DataFrame:
|
|
|
|
| 154 |
|
| 155 |
return pd.DataFrame(row_data, columns=['FA_ID', 'SR_ID', 'First_Name', 'Prefer_First_Name', 'Last_Name', 'Name_Suffix', 'Position', 'Team'])
|
| 156 |
|
| 157 |
+
tab1, tab2, tab3, tab4, tab5, tab6, tab7 = st.tabs(['Rankings Update', 'Projections Update', 'SR ID Update', 'Game Model Update', 'NCAAF Script', 'UR Push', 'Data updates'])
|
| 158 |
|
| 159 |
with tab1:
|
| 160 |
with st.container():
|
|
|
|
| 813 |
st.write("Error updating current season")
|
| 814 |
st.write(response.json())
|
| 815 |
st.cache_data.clear()
|
| 816 |
+
for key in st.session_state.keys():
|
| 817 |
+
del st.session_state[key]
|
| 818 |
+
|
| 819 |
+
with tab6:
|
| 820 |
+
with st.container():
|
| 821 |
+
st.header("Update Data Sources")
|
| 822 |
+
st.info("Select a specific data source to update and hit the button")
|
| 823 |
+
choose_data_source = st.selectbox("Choose Data Source", data_update_options, key='choose_data_source')
|
| 824 |
+
if st.button("Update Data", key='site_data_update'):
|
| 825 |
+
if choose_data_source == 'DFS':
|
| 826 |
+
response = requests.post(f"https://api.fantasylife.com/api/dfs/v1/force-update", headers=headers)
|
| 827 |
+
elif choose_data_source == 'DVP':
|
| 828 |
+
response = requests.post(f"https://api.fantasylife.com/api/dvp/v1/force-update", headers=headers)
|
| 829 |
+
elif choose_data_source == 'Air Yards':
|
| 830 |
+
response = requests.post(f"https://api.fantasylife.com/api/air-yards/v1/force-update", headers=headers)
|
| 831 |
+
elif choose_data_source == 'FAAB':
|
| 832 |
+
response = requests.post(f"https://api.fantasylife.com/api/waivers/v1/force-update", headers=headers)
|
| 833 |
+
if response.status_code == 200:
|
| 834 |
+
st.write("Uploading!")
|
| 835 |
+
st.write(response.json())
|
| 836 |
+
st.cache_data.clear()
|
| 837 |
+
for key in st.session_state.keys():
|
| 838 |
+
del st.session_state[key]
|
| 839 |
+
else:
|
| 840 |
+
st.write("Error updating site data")
|
| 841 |
+
st.write(response.json())
|
| 842 |
+
st.cache_data.clear()
|
| 843 |
for key in st.session_state.keys():
|
| 844 |
del st.session_state[key]
|