James McCool commited on
Commit
4307326
·
1 Parent(s): dc792cb

Removing debugs and setting the app to run. I'm just going to do debug by myself.

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +2 -15
src/streamlit_app.py CHANGED
@@ -176,14 +176,11 @@ def init_baselines(data_req: str):
176
  game_rot['GAME_DATE'] = pd.to_datetime(game_rot['GAME_DATE']).dt.date
177
 
178
  # Query play-by-play stint stats
179
- st.toast("DEBUG: Attempting to load stint stats...")
180
  try:
181
  collection = db["playbyplay_stints"]
182
  cursor = collection.find()
183
  stint_stats = pd.DataFrame(list(cursor))
184
 
185
- st.toast(f"DEBUG: Loaded {len(stint_stats)} stint_stats records")
186
-
187
  if len(stint_stats) > 0:
188
  # Create stint_id in game_rot for merging (ensure float format to match data hook)
189
  game_rot['stint_id'] = (game_rot['GAME_ID'].astype(str) + '_' +
@@ -204,25 +201,15 @@ def init_baselines(data_req: str):
204
  numeric_cols = [col for col in available_cols if col != 'stint_id']
205
  stint_stats_subset[numeric_cols] = stint_stats_subset[numeric_cols].apply(pd.to_numeric, errors='coerce')
206
 
207
- # DEBUG: Check matching before merge
208
- matching_ids = set(game_rot['stint_id']).intersection(set(stint_stats_subset['stint_id']))
209
- st.toast(f"DEBUG: {len(matching_ids)} matching stint_ids")
210
-
211
  # Merge stint stats with rotations
212
  game_rot = game_rot.merge(stint_stats_subset, on='stint_id', how='left')
213
 
214
- # DEBUG: Check result after merge
215
- non_zero_pts = (game_rot['stint_PTS'] > 0).sum() if 'stint_PTS' in game_rot.columns else 0
216
- st.toast(f"DEBUG: {non_zero_pts} non-zero stint_PTS after merge")
217
-
218
  # Fill NaN stint stats with 0
219
  for col in numeric_cols:
220
  if col in game_rot.columns:
221
  game_rot[col] = game_rot[col].fillna(0)
222
- except Exception as e:
223
- st.error(f"ERROR loading stint stats: {e}")
224
-
225
- st.toast("DEBUG: Stint stats section complete")
226
 
227
  return gamelog_table, game_rot, timestamp
228
 
 
176
  game_rot['GAME_DATE'] = pd.to_datetime(game_rot['GAME_DATE']).dt.date
177
 
178
  # Query play-by-play stint stats
 
179
  try:
180
  collection = db["playbyplay_stints"]
181
  cursor = collection.find()
182
  stint_stats = pd.DataFrame(list(cursor))
183
 
 
 
184
  if len(stint_stats) > 0:
185
  # Create stint_id in game_rot for merging (ensure float format to match data hook)
186
  game_rot['stint_id'] = (game_rot['GAME_ID'].astype(str) + '_' +
 
201
  numeric_cols = [col for col in available_cols if col != 'stint_id']
202
  stint_stats_subset[numeric_cols] = stint_stats_subset[numeric_cols].apply(pd.to_numeric, errors='coerce')
203
 
 
 
 
 
204
  # Merge stint stats with rotations
205
  game_rot = game_rot.merge(stint_stats_subset, on='stint_id', how='left')
206
 
 
 
 
 
207
  # Fill NaN stint stats with 0
208
  for col in numeric_cols:
209
  if col in game_rot.columns:
210
  game_rot[col] = game_rot[col].fillna(0)
211
+ except Exception:
212
+ pass # Silently continue if stint stats unavailable
 
 
213
 
214
  return gamelog_table, game_rot, timestamp
215