File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed
pems_streamlit/src/pems_streamlit/apps/stations Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change 3
3
import pandas as pd
4
4
import streamlit as st
5
5
6
- from pems_data .stations import StationsBucket
6
+ from pems_data .sources .s3 import S3DataSource
7
+ from pems_data .services .stations import StationsService
7
8
8
-
9
- BUCKET = StationsBucket ( )
9
+ BUCKET = S3DataSource ()
10
+ STATIONS = StationsService ( data_source = BUCKET )
10
11
11
12
12
13
@st .cache_data (ttl = 3600 ) # Cache for 1 hour
13
14
def load_station_metadata (district_number : str ) -> pd .DataFrame :
14
15
"""Loads metadata for all stations in the selected District from S3."""
15
- return BUCKET .get_district_metadata (district_number )
16
+ return STATIONS .get_district_metadata (district_number )
16
17
17
18
18
19
@st .cache_data (ttl = 3600 ) # Cache for 1 hour
@@ -30,12 +31,12 @@ def match(m: re.Match):
30
31
return BUCKET .get_prefixes (pattern , initial_prefix = BUCKET .imputation_detector_agg_5min , match_func = match )
31
32
32
33
33
- @st .cache_data (ttl = 3600 ) # Cache for 1 hour
34
+ @st .cache_data (ttl = 300 ) # Cache for 5 minutes
34
35
def load_station_data (station_id : str ) -> pd .DataFrame :
35
36
"""
36
37
Loads station data for a specific station.
37
38
"""
38
- return BUCKET .get_imputed_agg_5min (station_id )
39
+ return STATIONS .get_imputed_agg_5min (station_id )
39
40
40
41
41
42
# --- STREAMLIT APP ---
You can’t perform that action at this time.
0 commit comments