James McCool commited on
Commit
e5b862e
·
1 Parent(s): 8a794d7

Add guillotine projections update functionality in app.py, including seasonal, weekly, and rest of season options. Enhanced user interface with dedicated sections for each projection type and improved error handling for API interactions.

Browse files
Files changed (1) hide show
  1. app.py +87 -1
app.py CHANGED
@@ -279,7 +279,6 @@ with tab1:
279
  del st.session_state[key]
280
 
281
 
282
-
283
  with tab2:
284
  with st.container():
285
  st.header("Update Regular Projections")
@@ -367,6 +366,93 @@ with tab2:
367
  st.cache_data.clear()
368
  for key in st.session_state.keys():
369
  del st.session_state[key]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
370
 
371
  with tab3:
372
  with st.container():
 
279
  del st.session_state[key]
280
 
281
 
 
282
  with tab2:
283
  with st.container():
284
  st.header("Update Regular Projections")
 
366
  st.cache_data.clear()
367
  for key in st.session_state.keys():
368
  del st.session_state[key]
369
+
370
+ with st.container():
371
+ st.header("Update Guillotine Projections")
372
+ guillotine_seasonal_proj_col, guillotine_ros_proj_col, guillotine_weekly_proj_col = st.columns([3, 3, 3])
373
+
374
+ with guillotine_seasonal_proj_col:
375
+ st.info("Update Seasonal Guillotine Projections")
376
+ choose_guillotine_seasonal_type = st.selectbox("Choose Type", proj_source_options, key='seasonal_guillotine_type')
377
+ choose_guillotine_seasonal_type = proj_replace_options[proj_source_options.index(choose_guillotine_seasonal_type)]
378
+ if st.button("Update Seasonal Guillotine Projections", key='seasonal_guillotine_projections'):
379
+ response = requests.post(f"https://api.fantasylife.com/api/projections/v1/{choose_guillotine_seasonal_type}/seasonal/update", headers=headers)
380
+ if response.status_code == 200:
381
+ st.write("Uploading!")
382
+ st.write(response.json())
383
+ st.cache_data.clear()
384
+ for key in st.session_state.keys():
385
+ del st.session_state[key]
386
+ else:
387
+ st.write("Error uploading seasonal guillotine aggregate projections")
388
+ st.write(response.json())
389
+ st.cache_data.clear()
390
+ for key in st.session_state.keys():
391
+ del st.session_state[key]
392
+ response = requests.post(f"https://api.fantasylife.com/api/projections/v1/aggregate/seasonal/update", headers=headers)
393
+ if response.status_code == 200:
394
+ st.write("Uploading Aggregate as well.")
395
+ else:
396
+ st.write("Error uploading seasonal guillotine aggregate projections")
397
+ st.write(response.json())
398
+ st.cache_data.clear()
399
+ for key in st.session_state.keys():
400
+ del st.session_state[key]
401
+ with guillotine_weekly_proj_col:
402
+ st.info("Update Weekly Guillotine Projections")
403
+ choose_guillotine_weekly_type = st.selectbox("Choose Type", proj_source_options, key='weekly_guillotine_type')
404
+ choose_guillotine_weekly_type = proj_replace_options[proj_source_options.index(choose_guillotine_weekly_type)]
405
+ if st.button("Update Weekly Guillotine Projections", key='weekly_guillotine_projections'):
406
+ response = requests.post(f"https://api.fantasylife.com/api/projections/v1/{choose_guillotine_weekly_type}/weekly/update", headers=headers)
407
+ if response.status_code == 200:
408
+ st.write("Uploading!")
409
+ st.write(response.json())
410
+ st.cache_data.clear()
411
+ for key in st.session_state.keys():
412
+ del st.session_state[key]
413
+ else:
414
+ st.write("Error uploading weekly guillotine projections")
415
+ st.write(response.json())
416
+ st.cache_data.clear()
417
+ for key in st.session_state.keys():
418
+ del st.session_state[key]
419
+ response = requests.post(f"https://api.fantasylife.com/api/projections/v1/aggregate/weekly/update", headers=headers)
420
+ if response.status_code == 200:
421
+ st.write("Uploading Aggregate as well.")
422
+ else:
423
+ st.write("Error uploading weekly guillotine aggregate projections")
424
+ st.write(response.json())
425
+ st.cache_data.clear()
426
+ for key in st.session_state.keys():
427
+ del st.session_state[key]
428
+
429
+ with guillotine_ros_proj_col:
430
+ st.info("Update Rest of Season Guillotine Projections")
431
+ choose_guillotine_ros_type = st.selectbox("Choose Type", ros_source_options, key='rest_of_season_guillotine_type')
432
+ choose_guillotine_ros_type = ros_replace_options[ros_source_options.index(choose_guillotine_ros_type)]
433
+ if st.button("Update Rest of Season Guillotine Projections", key='rest_of_season_guillotine_projections'):
434
+ response = requests.post(f"https://api.fantasylife.com/api/projections/v1/{choose_guillotine_ros_type}/restofseason/update", headers=headers)
435
+ if response.status_code == 200:
436
+ st.write("Uploading!")
437
+ st.write(response.json())
438
+ st.cache_data.clear()
439
+ for key in st.session_state.keys():
440
+ del st.session_state[key]
441
+ else:
442
+ st.write("Error uploading rest of season guillotine projections")
443
+ st.write(response.json())
444
+ st.cache_data.clear()
445
+ for key in st.session_state.keys():
446
+ del st.session_state[key]
447
+ response = requests.post(f"https://api.fantasylife.com/api/projections/v1/aggregate/restofseason/update", headers=headers)
448
+ if response.status_code == 200:
449
+ st.write("Uploading Aggregate as well.")
450
+ else:
451
+ st.write("Error uploading rest of season guillotine aggregate projections")
452
+ st.write(response.json())
453
+ st.cache_data.clear()
454
+ for key in st.session_state.keys():
455
+ del st.session_state[key]
456
 
457
  with tab3:
458
  with st.container():