Jon Solow commited on
Commit
3eebb0d
·
1 Parent(s): 3674bbc

Link to data loader if data not loaded from snaps

Browse files
src/pages/7_Snap_Counts.py CHANGED
@@ -5,7 +5,7 @@ from config import DEFAULT_ICON
5
  from shared_page import common_page_config
6
 
7
  from queries.footballguys.constants import YEAR
8
- from queries.nflverse.github_data import get_snap_counts
9
 
10
 
11
  @st.cache_data(ttl=60 * 60 * 24)
@@ -26,6 +26,9 @@ def get_page():
26
  st.title(page_title)
27
  if st.button("Refresh Data"):
28
  st.cache_data.clear()
 
 
 
29
  data, teams_list, position_list, weeks_list, data_load_time_str = load_data()
30
  st.write(f"Data loaded as of: {data_load_time_str} UTC")
31
  teams_selected = st.multiselect("Team:", teams_list, placeholder="Select a team to filter") or teams_list
 
5
  from shared_page import common_page_config
6
 
7
  from queries.footballguys.constants import YEAR
8
+ from queries.nflverse.github_data import get_snap_counts, get_current_tables, SEASON
9
 
10
 
11
  @st.cache_data(ttl=60 * 60 * 24)
 
26
  st.title(page_title)
27
  if st.button("Refresh Data"):
28
  st.cache_data.clear()
29
+ if f"snap_counts_snap_counts_{SEASON}" not in get_current_tables():
30
+ st.write("Data not loaded. Check loaded data [here](./Load_Data)")
31
+ return
32
  data, teams_list, position_list, weeks_list, data_load_time_str = load_data()
33
  st.write(f"Data loaded as of: {data_load_time_str} UTC")
34
  teams_selected = st.multiselect("Team:", teams_list, placeholder="Select a team to filter") or teams_list
src/pages/98_Load_Data.py CHANGED
@@ -4,7 +4,7 @@ import streamlit as st
4
  from config import DEFAULT_ICON
5
  from shared_page import common_page_config
6
 
7
- from queries.nflverse.github_data import load_assets
8
 
9
 
10
  def get_page():
@@ -13,8 +13,7 @@ def get_page():
13
  common_page_config()
14
  st.title(page_title)
15
 
16
- current_tables_df = duckdb.sql("SHOW TABLES").df()
17
- current_tables_list = current_tables_df["name"].tolist()
18
 
19
  if st.button("Refresh Data"):
20
  load_assets()
 
4
  from config import DEFAULT_ICON
5
  from shared_page import common_page_config
6
 
7
+ from queries.nflverse.github_data import load_assets, get_current_tables
8
 
9
 
10
  def get_page():
 
13
  common_page_config()
14
  st.title(page_title)
15
 
16
+ current_tables_list = get_current_tables()
 
17
 
18
  if st.button("Refresh Data"):
19
  load_assets()
src/queries/nflverse/github_data.py CHANGED
@@ -70,6 +70,13 @@ NFLVERSE_ASSETS = [
70
  ]
71
 
72
 
 
 
 
 
 
 
 
73
  class NflVerseDataAsset:
74
  def __init__(
75
  self,
@@ -97,3 +104,8 @@ def load_assets():
97
  for tag, asset in NFLVERSE_ASSETS:
98
  asset = NflVerseDataAsset(tag, asset)
99
  asset.register_asset_to_duckdb()
 
 
 
 
 
 
70
  ]
71
 
72
 
73
+ PAGE_TO_TABLE_MAP = {
74
+ "Snap_Counts": f"snap_counts_snap_counts_{SEASON}",
75
+ "FTN_Charting": f"ftn_charting_ftn_charting_{SEASON}",
76
+ "Team_Formations": f"pbp_participation_pbp_participation_{SEASON}",
77
+ }
78
+
79
+
80
  class NflVerseDataAsset:
81
  def __init__(
82
  self,
 
104
  for tag, asset in NFLVERSE_ASSETS:
105
  asset = NflVerseDataAsset(tag, asset)
106
  asset.register_asset_to_duckdb()
107
+
108
+
109
+ def get_current_tables() -> list[str]:
110
+ current_tables_df = duckdb.sql("SHOW TABLES").df()
111
+ return current_tables_df["name"].tolist()