From f52ff3c3e02f4cf3f7b69bc3cacdb8e5f232d220 Mon Sep 17 00:00:00 2001 From: Peter Dudfield <34686298+peterdudfield@users.noreply.github.com> Date: Tue, 5 Sep 2023 16:42:19 +0100 Subject: [PATCH 1/2] Issue/dont save if nan (#72) * drop nans if in generation_mw * pydantic<2.0 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * if capacity is zero, fill nans * only update location if there are results * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- gspconsumer/app.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/gspconsumer/app.py b/gspconsumer/app.py index a712f60..f676bab 100644 --- a/gspconsumer/app.py +++ b/gspconsumer/app.py @@ -194,6 +194,10 @@ def pull_data_and_save( else: logger.debug(f"This is the first lot gsp yield data for GSP {(gsp.gsp_id)}") + # capacity is zero, set nans to 0 + if gsp_yield_df["capacity_mwp"].sum() == 0: + gsp_yield_df["generation_mw"] = 0 + # drop any nan values in generation_mw column gsp_yield_df = gsp_yield_df.dropna(subset=["generation_mw"]) @@ -221,14 +225,15 @@ def pull_data_and_save( gsp_yield_sql.location = gsp # update installed capacity - current_installed_capacity = gsp_yield_sql.location.installed_capacity_mw - new_installed_capacity = gsp_yield_df["installedcapacity_mwp"].iloc[0] - if current_installed_capacity != new_installed_capacity: - logger.debug( - f"Going to update the capacity from " - f"{current_installed_capacity} to {new_installed_capacity}" - ) - gsp_yield_sql.location.installed_capacity_mw = new_installed_capacity + if len(gsp_yield_df) > 0: + current_installed_capacity = gsp_yield_sql.location.installed_capacity_mw + new_installed_capacity = gsp_yield_df["installedcapacity_mwp"].iloc[0] + if current_installed_capacity != new_installed_capacity: + logger.debug( + f"Going to update the capacity from " + f"{current_installed_capacity} to {new_installed_capacity}" + ) + gsp_yield_sql.location.installed_capacity_mw = new_installed_capacity logger.debug(f"Found {len(gsp_yields_sql)} gsp yield for GSPs {gsp.gsp_id}") From 631a3727b4b5d2eecaa4c00baaec89ba442b27a8 Mon Sep 17 00:00:00 2001 From: BumpVersion Action Date: Tue, 5 Sep 2023 15:42:46 +0000 Subject: [PATCH 2/2] =?UTF-8?q?Bump=20version:=201.1.9=20=E2=86=92=201.1.1?= =?UTF-8?q?0=20[skip=20ci]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .bumpversion.cfg | 2 +- gspconsumer/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 36cc1a3..d7130e9 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,7 +1,7 @@ [bumpversion] commit = True tag = True -current_version = 1.1.9 +current_version = 1.1.10 message = Bump version: {current_version} → {new_version} [skip ci] [bumpversion:file:gspconsumer/__init__.py] diff --git a/gspconsumer/__init__.py b/gspconsumer/__init__.py index bf18799..dcefa13 100644 --- a/gspconsumer/__init__.py +++ b/gspconsumer/__init__.py @@ -1,2 +1,2 @@ """ Pv Consumer""" -__version__ = "1.1.9" +__version__ = "1.1.10"