|
8 | 8 | from sqlalchemy.orm.session import Session
|
9 | 9 |
|
10 | 10 | from nowcasting_datamodel.models.models import ForecastSQL, ForecastValueLatestSQL
|
11 |
| -from nowcasting_datamodel.read.read import get_latest_forecast, get_model, get_latest_forecast_for_gsps |
| 11 | +from nowcasting_datamodel.read.read import ( |
| 12 | + get_latest_forecast, |
| 13 | + get_model, |
| 14 | + get_latest_forecast_for_gsps, |
| 15 | +) |
12 | 16 |
|
13 | 17 | logger = logging.getLogger(__name__)
|
14 | 18 |
|
@@ -66,7 +70,9 @@ def upsert(session: Session, model, rows: List[dict]):
|
66 | 70 | session.execute(stmt, rows)
|
67 | 71 |
|
68 | 72 |
|
69 |
| -def update_forecast_latest(forecast: ForecastSQL, session: Session, forecast_historic: Optional[ForecastSQL] = None): |
| 73 | +def update_forecast_latest( |
| 74 | + forecast: ForecastSQL, session: Session, forecast_historic: Optional[ForecastSQL] = None |
| 75 | +): |
70 | 76 | """
|
71 | 77 | Update the forecast_values table
|
72 | 78 |
|
@@ -116,7 +122,11 @@ def update_all_forecast_latest(forecasts: List[ForecastSQL], session: Session):
|
116 | 122 |
|
117 | 123 | # chose the correct forecast historic
|
118 | 124 | gsp_id = forecast.location.gsp_id
|
119 |
| - forecast_historic = [forecast for forecast in forecasts_historic if forecast.location.gsp_id == gsp_id] |
| 125 | + forecast_historic = [ |
| 126 | + forecast for forecast in forecasts_historic if forecast.location.gsp_id == gsp_id |
| 127 | + ] |
120 | 128 | forecast_historic = forecast_historic[0]
|
121 | 129 |
|
122 |
| - update_forecast_latest(forecast=forecast, session=session, forecast_historic=forecast_historic) |
| 130 | + update_forecast_latest( |
| 131 | + forecast=forecast, session=session, forecast_historic=forecast_historic |
| 132 | + ) |
0 commit comments