Skip to content

Commit

Permalink
Issue/add ml model (#151)
Browse files Browse the repository at this point in the history
* #147 add ml model

* add migration for datamodel

* add model filter + tests

* PR comment, rename function

* fix

* add to test
  • Loading branch information
peterdudfield authored Aug 12, 2024
1 parent 79957bb commit 38f9ee8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion pvsite_datamodel/write/forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def insert_forecast_values(
:param session: sqlalchemy session for interacting with the database
:param forecast_meta: Meta info about the forecast values
:param forecast_values_df: dataframe with the data to insert
:param ml_model_name: name of the ML model used to generate the forecast
:param ml_model_version: version of the ML model used to generate the forecast
"""

forecast = ForecastSQL(**forecast_meta)
Expand All @@ -36,7 +38,7 @@ def insert_forecast_values(

if (ml_model_name is not None) and (ml_model_version is not None):
ml_model = get_or_create_model(session, ml_model_name, ml_model_version)
ml_model_uuid = ml_model.uuid
ml_model_uuid = ml_model.model_uuid
else:
ml_model_uuid = None

Expand Down
8 changes: 7 additions & 1 deletion tests/test_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@ def test_insert_forecast_for_existing_site(self, db_session, forecast_valid_inpu
assert ptypes.is_numeric_dtype(forecast_values_df["forecast_power_kw"])
assert ptypes.is_numeric_dtype(forecast_values_df["horizon_minutes"])

insert_forecast_values(db_session, forecast_meta, forecast_values_df)
insert_forecast_values(
db_session,
forecast_meta,
forecast_values_df,
ml_model_name="test",
ml_model_version="0.0.0",
)

assert db_session.query(ForecastSQL).count() == 1
assert db_session.query(ForecastValueSQL).count() == 10
Expand Down

0 comments on commit 38f9ee8

Please sign in to comment.