Skip to content

Commit 67fb3f2

Browse files
authored
fix: refactor data loading services and update dependencies
fix: refactor data loading services and update dependencies
2 parents cfb22ca + 6daa1fc commit 67fb3f2

21 files changed

Lines changed: 330 additions & 209 deletions

.github/workflows/cache-uv-build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
build-cache:
88
runs-on: ubuntu-latest
99
env:
10-
UV_VERSION: '0.10.8'
10+
UV_VERSION: '0.10.10'
1111
PYTHON_VERSION: '3.13'
1212
steps:
1313
- name: Checkout repository

.github/workflows/docker-build-and-scan.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ jobs:
2828
- name: Checkout repository
2929
uses: actions/checkout@v6
3030
- name: Set up QEMU
31-
uses: docker/setup-qemu-action@v3
31+
uses: docker/setup-qemu-action@v4
3232
- name: Set up Docker Buildx
33-
uses: docker/setup-buildx-action@v3
33+
uses: docker/setup-buildx-action@v4
3434
- name: Login to DockerHub
35-
uses: docker/login-action@v3
35+
uses: docker/login-action@v4
3636
with:
3737
username: ${{ vars.DOCKERHUB_USERNAME }}
3838
password: ${{ secrets.DOCKERHUB_TOKEN }}
3939
- name: Build (and maybe push) Docker image
40-
uses: docker/build-push-action@v6
40+
uses: docker/build-push-action@v7
4141
with:
4242
context: ${{ inputs.DOCKER_PATH_CONTEXT }}
4343
file: ${{ inputs.DOCKER_BUILD_DOCKERFILE}}
@@ -46,7 +46,7 @@ jobs:
4646
tags: ${{ inputs.DOCKER_TAGS }}
4747
- name: Run Trivy vulnerability scanner (remote)
4848
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }}
49-
uses: aquasecurity/trivy-action@0.34.1
49+
uses: aquasecurity/trivy-action@0.35.0
5050
with:
5151
image-ref: docker.io/${{ inputs.DOCKER_TAGS }}
5252
format: 'table'

.github/workflows/pytest.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
permissions:
1010
contents: read
1111
env:
12-
UV_VERSION: '>=0.10.8'
12+
UV_VERSION: '>=0.10.10'
1313
PYTHON_VERSION: '3.13'
1414
steps:
1515
- name: Checkout repository

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
dist_artifacts_name: dist
1616
dist_artifacts_dir: dist
1717
lock_file_artifact: uv.lock
18-
UV_VERSION: '>=0.10.8'
18+
UV_VERSION: '>=0.10.10'
1919
PYTHON_VERSION: '3.13'
2020
GITHUB_ACTIONS_AUTHOR_NAME: github-actions
2121
GITHUB_ACTIONS_AUTHOR_EMAIL: actions@users.noreply.github.com
File renamed without changes.

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ readme = "README.md"
66
requires-python = ">=3.13"
77
dependencies = [
88
"apscheduler>=3.11.2",
9-
"black>=26.1.0",
9+
"black>=26.3.1",
1010
"coverage>=7.13.2",
1111
"httpx>=0.28.1",
1212
"isort>=8.0.1",
@@ -20,14 +20,14 @@ dependencies = [
2020
"pylint-pydantic>=0.4.1",
2121
"pytest>=9.0.2",
2222
"rich>=14.3.2",
23-
"ruff>=0.15.2",
23+
"ruff>=0.15.6",
2424
]
2525

2626
[project.optional-dependencies]
2727
build = ["uv >= 0.10.7"]
2828

2929
[build-system]
30-
requires = ["uv_build >= 0.10.7"]
30+
requires = ["uv_build >= 0.10.10"]
3131
build-backend = "uv_build"
3232

3333
[project.scripts]

src/sample_python_app/app/runner.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,22 @@
1616
from sample_python_app.exceptions import AppError
1717
from sample_python_app.services import (
1818
CustomHTTPClient,
19-
fetch_astronomical_data_from_api,
2019
fetch_hourly_forecast_from_api,
20+
fetch_weather_point_data,
2121
set_next_hour_forecast_temperature,
2222
)
2323
from sample_python_app.ui import display_astronomical_data
2424

2525

26+
def extract_astronomical_data(weather_point_data):
27+
"""Extract the astronomical data from a WeatherPointDataFeature object."""
28+
if hasattr(weather_point_data, "properties") and hasattr(
29+
weather_point_data.properties, "astronomical_data"
30+
):
31+
return weather_point_data.properties.astronomical_data
32+
raise AttributeError("Input does not have properties.astronomical_data")
33+
34+
2635
class AstroFetcher:
2736
"""Fetches astronomical data and displays only once per day.
2837
@@ -45,7 +54,7 @@ def fetch(self, *, exit_on_error: bool = True) -> None:
4554
start = time.time()
4655

4756
try:
48-
astro = fetch_astronomical_data_from_api(lat, lon, client=self.client)
57+
weather_point_data = fetch_weather_point_data(lat, lon, client=self.client)
4958
forecast = fetch_hourly_forecast_from_api(lat, lon, client=self.client)
5059
set_next_hour_forecast_temperature(forecast, location=f"{lat},{lon}")
5160
FETCH_COUNTER.inc()
@@ -60,7 +69,8 @@ def fetch(self, *, exit_on_error: bool = True) -> None:
6069
today = date.today().isoformat()
6170

6271
if self._last_displayed_day != today:
63-
display_astronomical_data(astro, forecast)
72+
astro_data = extract_astronomical_data(weather_point_data)
73+
display_astronomical_data(astro_data, forecast)
6474
self._last_displayed_day = today
6575

6676
def reset_display(self):
@@ -91,9 +101,6 @@ def shutdown_runner() -> None:
91101
"""Shutdown helper to close long-lived resources owned by the runner.
92102
93103
Call this from application shutdown hooks to ensure the HTTP client is
94-
properly closed and connections are released.
104+
properly closed and resources are released.
95105
"""
96-
try:
97-
fetcher.close()
98-
except Exception:
99-
logger.exception("Error during runner shutdown")
106+
fetcher.close()
Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1-
"""Models package for weather.gov API response parsing."""
1+
"""Re-export weather models for convenience."""
22

3-
from sample_python_app.models.forecast_geojson import ForecastFeature
4-
from sample_python_app.models.weather_gov import AstronomicalData, WeatherGovFeature
3+
from sample_python_app.models.weather import (
4+
AstronomicalData,
5+
CurrentConditionsFeature,
6+
ForecastFeature,
7+
WeatherPointDataFeature,
8+
)
59

6-
__all__ = ["WeatherGovFeature", "AstronomicalData", "ForecastFeature"]
10+
__all__ = [
11+
"WeatherPointDataFeature",
12+
"ForecastFeature",
13+
"AstronomicalData",
14+
"CurrentConditionsFeature",
15+
]

src/sample_python_app/models/forecast_geojson.py

Lines changed: 0 additions & 59 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""Models package for weather.gov API response parsing."""
2+
3+
from sample_python_app.models.weather.current_conditions_point import (
4+
CurrentConditionsFeature,
5+
)
6+
from sample_python_app.models.weather.forecast_geojson import ForecastFeature
7+
from sample_python_app.models.weather.weather_gov import (
8+
AstronomicalData,
9+
WeatherPointDataFeature,
10+
)
11+
12+
__all__ = [
13+
"WeatherPointDataFeature",
14+
"ForecastFeature",
15+
"CurrentConditionsFeature",
16+
"AstronomicalData",
17+
]

0 commit comments

Comments
 (0)