Skip to content

Commit

Permalink
Backport PR #864: fix: apply soc-unit when deserializing soc-minima a…
Browse files Browse the repository at this point in the history
…nd soc-maxima (#864)

* fix: apply soc-unit when deserializing soc-minima and soc-maxima

Signed-off-by: F.N. Claessen <felix@seita.nl>

* docs: changelog entry

Signed-off-by: F.N. Claessen <felix@seita.nl>

* docs: changelog entries for additional backports

Signed-off-by: F.N. Claessen <felix@seita.nl>

---------

Signed-off-by: F.N. Claessen <felix@seita.nl>
  • Loading branch information
Flix6x committed Oct 2, 2023
1 parent db9282f commit c614d5e
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
32 changes: 31 additions & 1 deletion documentation/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@
FlexMeasures Changelog
**********************

v0.16.0 | September XX, 2023

v0.16.1 | October 2, 2023
============================

Bugfixes
-----------

* Fix infeasible problem due to incorrect parsing of soc units of the ``soc-minima`` and ``soc-maxima`` fields within the ``flex-model`` field [see `PR #864 <https://github.com/FlexMeasures/flexmeasures/pull/864>`_]


v0.16.0 | September 27, 2023
============================

New features
Expand All @@ -26,6 +36,15 @@ Infrastructure / Support
* Have our CI pipeline (GitHub Actions) build the Docker image and make a schedule [see `PR #800 <https://github.com/FlexMeasures/flexmeasures/pull/800>`_]


v0.15.2 | October 2, 2023
============================

Bugfixes
-----------

* Fix infeasible problem due to incorrect parsing of soc units of the ``soc-minima`` and ``soc-maxima`` fields within the ``flex-model`` field [see `PR #864 <https://github.com/FlexMeasures/flexmeasures/pull/864>`_]


v0.15.1 | August 28, 2023
============================

Expand All @@ -38,6 +57,7 @@ Bugfixes
* Fix showing sensor data on the asset page of public assets, and searching for annotations on public assets [see `PR #830 <https://github.com/FlexMeasures/flexmeasures/pull/830>`_]
* Make the command `flexmeasures add schedule for-storage` to pass the soc-target timestamp to the flex model as strings instead of `pd.Timestamp` [see `PR #834 <https://github.com/FlexMeasures/flexmeasures/pull/834>`_]


v0.15.0 | August 9, 2023
============================

Expand Down Expand Up @@ -82,6 +102,16 @@ Infrastructure / Support
* Start keeping sets of pinned requirements per supported Python version. Also fixes recent Docker build problem. [see `PR #776 <https://www.github.com/FlexMeasures/flexmeasures/pull/776>`_]
* Removed obsolete code dealing with deprecated data models (e.g. assets, markets and weather sensors), and sunset the fm0 scheme for entity addresses [see `PR #695 <https://www.github.com/FlexMeasures/flexmeasures/pull/695>`_ and `project 11 <https://www.github.com/FlexMeasures/flexmeasures/projects/11>`_]


v0.14.3 | October 2, 2023
============================

Bugfixes
-----------

* Fix infeasible problem due to incorrect parsing of soc units of the ``soc-minima`` and ``soc-maxima`` fields within the ``flex-model`` field [see `PR #864 <https://github.com/FlexMeasures/flexmeasures/pull/864>`_]


v0.14.2 | July 25, 2023
============================

Expand Down
7 changes: 7 additions & 0 deletions flexmeasures/api/v3_0/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,11 @@ def message_for_trigger_schedule(
message["flex-model"]["soc-targets"] = [
{"value": target_value, "datetime": target_datetime}
]
# Also create some minima and maxima constraints to test correct deserialization using the soc-unit
message["flex-model"]["soc-minima"] = [
{"value": target_value - 1, "datetime": target_datetime}
]
message["flex-model"]["soc-maxima"] = [
{"value": target_value + 1, "datetime": target_datetime}
]
return message
6 changes: 6 additions & 0 deletions flexmeasures/data/schemas/scheduling/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ def post_load_sequence(self, data: dict, **kwargs) -> dict:
if data.get("soc_targets"):
for target in data["soc_targets"]:
target["value"] /= 1000.0
if data.get("soc_minima"):
for minimum in data["soc_minima"]:
minimum["value"] /= 1000.0
if data.get("soc_maxima"):
for maximum in data["soc_maxima"]:
maximum["value"] /= 1000.0
data["soc_unit"] = "MWh"

# Convert efficiencies to dimensionless (to the (0,1] range)
Expand Down

0 comments on commit c614d5e

Please sign in to comment.