James McCool commited on
Commit
22ac9e4
·
1 Parent(s): 28939d0

Enhance session state management in app.py for contest and projections files

Browse files

- Updated logic to check for existing adjusted dataframes in session state before loading new files, preventing overwrites and ensuring data integrity.
- Improved clarity in the handling of contest and projections file uploads by incorporating checks for 'Adj_Contest' and 'Adj_projections_df' in session state.

Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -35,7 +35,7 @@ with tab1:
35
  if 'Contest' in st.session_state:
36
  del st.session_state['Contest']
37
 
38
- if Contest_file:
39
  st.session_state['Contest'], st.session_state['ownership_df'], st.session_state['actual_df'], st.session_state['entry_list'] = load_contest_file(Contest_file, sport_select)
40
  st.session_state['Contest'] = st.session_state['Contest'].dropna(how='all')
41
  st.session_state['Contest'] = st.session_state['Contest'].reset_index(drop=True)
@@ -66,7 +66,7 @@ with tab1:
66
  mime="text/csv"
67
  )
68
 
69
- if projections_file:
70
  export_projections, st.session_state['projections_df'] = load_file(projections_file)
71
  if st.session_state['projections_df'] is not None:
72
  st.success('Projections file loaded successfully!')
 
35
  if 'Contest' in st.session_state:
36
  del st.session_state['Contest']
37
 
38
+ if Contest_file and 'Adj_Contest' not in st.session_state:
39
  st.session_state['Contest'], st.session_state['ownership_df'], st.session_state['actual_df'], st.session_state['entry_list'] = load_contest_file(Contest_file, sport_select)
40
  st.session_state['Contest'] = st.session_state['Contest'].dropna(how='all')
41
  st.session_state['Contest'] = st.session_state['Contest'].reset_index(drop=True)
 
66
  mime="text/csv"
67
  )
68
 
69
+ if projections_file and 'Adj_projections_df' not in st.session_state:
70
  export_projections, st.session_state['projections_df'] = load_file(projections_file)
71
  if st.session_state['projections_df'] is not None:
72
  st.success('Projections file loaded successfully!')