Skip to content

Commit 376d13f

Browse files
committed
refactor(pems_streamlit): use the new source and service
1 parent 05d1f40 commit 376d13f

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

pems_streamlit/src/pems_streamlit/apps/stations/app_stations.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@
33
import pandas as pd
44
import streamlit as st
55

6-
from pems_data.stations import StationsBucket
6+
from pems_data.sources.s3 import S3DataSource
7+
from pems_data.services.stations import StationsService
78

8-
9-
BUCKET = StationsBucket()
9+
BUCKET = S3DataSource()
10+
STATIONS = StationsService(data_source=BUCKET)
1011

1112

1213
@st.cache_data(ttl=3600) # Cache for 1 hour
1314
def load_station_metadata(district_number: str) -> pd.DataFrame:
1415
"""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)
1617

1718

1819
@st.cache_data(ttl=3600) # Cache for 1 hour
@@ -30,12 +31,12 @@ def match(m: re.Match):
3031
return BUCKET.get_prefixes(pattern, initial_prefix=BUCKET.imputation_detector_agg_5min, match_func=match)
3132

3233

33-
@st.cache_data(ttl=3600) # Cache for 1 hour
34+
@st.cache_data(ttl=300) # Cache for 5 minutes
3435
def load_station_data(station_id: str) -> pd.DataFrame:
3536
"""
3637
Loads station data for a specific station.
3738
"""
38-
return BUCKET.get_imputed_agg_5min(station_id)
39+
return STATIONS.get_imputed_agg_5min(station_id)
3940

4041

4142
# --- STREAMLIT APP ---

0 commit comments

Comments
 (0)