Skip to content

Commit becb74b

Browse files
committed
override site model name if site.ml_model is not assigned
1 parent b79c344 commit becb74b

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ classifiers = ["Programming Language :: Python :: 3"]
1919
dependencies = [
2020
"cryptography >= 42.0.7",
2121
"fastapi >= 0.105.0",
22-
"pvsite-datamodel >= 1.0.41",
22+
"pvsite-datamodel >= 1.0.45",
2323
"pyjwt >= 2.8.0",
2424
"pyproj >= 3.3.0",
2525
"pytz >= 2023.3",

src/india_api/internal/inputs/indiadb/client.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
get_pv_generation_by_sites,
1414
get_user_by_email,
1515
get_sites_from_user,
16+
get_site_by_uuid,
1617
)
1718
from pvsite_datamodel.write.generation import insert_generation_values
1819
from pvsite_datamodel.sqlmodels import SiteAssetType, ForecastValueSQL
@@ -103,6 +104,10 @@ def get_predicted_power_production_for_location(
103104

104105
site = sites[0]
105106

107+
if site.ml_model is not None:
108+
ml_model_name = site.ml_model.model_name
109+
log.info(f"Using ml model {site.ml_model.model_name}")
110+
106111
# read actual generations
107112
values = get_latest_forecast_values_by_site(
108113
session,
@@ -286,6 +291,12 @@ def get_site_forecast(self, site_uuid: str, email: str) -> list[internal.Predict
286291
with self._get_session() as session:
287292
check_user_has_access_to_site(session=session, email=email, site_uuid=site_uuid)
288293

294+
# get site and the get the ml model name
295+
site = get_site_by_uuid(session=session, site_uuid=site_uuid)
296+
if site.ml_model is not None:
297+
ml_model_name = site.ml_model.model_name
298+
log.info(f"Using ml model {site.ml_model.model_name}")
299+
289300
if isinstance(site_uuid, str):
290301
site_uuid = UUID(site_uuid)
291302

0 commit comments

Comments
 (0)