Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion documentation/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ New features
* Floor off-clock API datetimes to a non-instantaneous sensor's resolution by default when ingesting sensor data, uploading sensor data, and handling scheduler flex-model timed events; configurable with the ``floor_datetimes_to_resolution`` sensor attribute [see `PR #2146 <https://www.github.com/FlexMeasures/flexmeasures/pull/2146>`_]
* Sensor references in flex-model and flex-context support various ways of filtering by source [see `PR #2209 <https://www.github.com/FlexMeasures/flexmeasures/pull/2209>`_]
* Let storage scheduling infer missing ``power-capacity`` from directional device capacities before falling back to site capacity, and default the missing opposite capacity to zero when only a non-zero ``consumption-capacity`` or ``production-capacity`` is configured [see `PR #2222 <https://www.github.com/FlexMeasures/flexmeasures/pull/2222>`_]
* Support multiple feeders to a shared storage [see `PR #2001 <https://www.github.com/FlexMeasures/flexmeasures/pull/2001>`_ ]
* Support multiple feeders to a shared storage [see `PR #2001 <https://www.github.com/FlexMeasures/flexmeasures/pull/2001>`_ and `PR #2321 <https://www.github.com/FlexMeasures/flexmeasures/pull/2321>`_]
* The flex-context can now define multiple commodities, each specifying their own prices and grid capacities [see `PR #1946 <https://www.github.com/FlexMeasures/flexmeasures/pull/1946>`_, `PR #2172 <https://www.github.com/FlexMeasures/flexmeasures/pull/2172>`_, `PR #2235 <https://www.github.com/FlexMeasures/flexmeasures/pull/2235>`_ and `PR #2271 <https://www.github.com/FlexMeasures/flexmeasures/pull/2271>`_]
* CLI support for adding/editing account attributes [see `PR #2242 <https://www.github.com/FlexMeasures/flexmeasures/pull/2242>`_]
* Improve chart axis domain for event values not around zero, with a per-sub-chart ``y-axis`` option in ``sensors_to_show`` (default ``zero``, which pads the axis out to include zero) that can be set to ``data`` to fit a sub-chart's y-axis to the values shown, to an explicit ``[min, max]`` domain that the axis will cover at least (expanding to fit data beyond it), or to a strict ``{"min": min, "max": max}`` domain that the axis will never exceed (clamping data beyond it, with a warning when that happens), editable from the graph editor [see `PR #2244 <https://www.github.com/FlexMeasures/flexmeasures/pull/2244>`_]
Expand All @@ -43,6 +43,7 @@ Infrastructure / Support
* Warn hosts when the database schema is not at the latest migration, and skip startup template provisioning until migrations are applied [see `PR #2309 <https://www.github.com/FlexMeasures/flexmeasures/pull/2309>`_]
* Stop manual runs of the Docker publishing workflow from overwriting the ``latest`` image tag, and let them opt in to it explicitly [see `PR #2316 <https://www.github.com/FlexMeasures/flexmeasures/pull/2316>`_]
* Add a pre-commit hook that blocks image files (png, jpg, gif, bmp, tiff, webp, ico, psd) from being committed outside of ``flexmeasures/ui/static/`` and ``documentation/``, to protect the git history from binary bloat; screenshots belong in the ``FlexMeasures/screenshots`` repo instead [see `PR #2315 <https://www.github.com/FlexMeasures/flexmeasures/pull/2315>`_]
* Schedulers track devices via a typed device inventory, which classifies every flex-model entry once and serves as the single source of truth for device roles and canonical device indices [see `PR #2321 <https://www.github.com/FlexMeasures/flexmeasures/pull/2321>`_]

Bugfixes
-----------
Expand Down
1 change: 1 addition & 0 deletions flexmeasures/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1371,6 +1371,7 @@ def create_charging_station_assets(
)
db.session.add(bi_soc)
db.session.add(uni_soc)
db.session.flush() # assign IDs, so tests don't depend on earlier tests flushing
return {
"Test charging station": charging_station,
"Test charging station (bidirectional)": bidirectional_charging_station,
Expand Down
4 changes: 3 additions & 1 deletion flexmeasures/data/models/generic_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,9 @@ def get_flex_context(self) -> dict:
flex_context = {}
parent_asset = self.parent_asset
while set(flex_context.keys()) != flex_context_field_names and parent_asset:
flex_context = {**parent_asset.flex_context, **flex_context}
# An ancestor's flex_context may still be None (e.g. a pending asset
# created without one, before its column default is applied on flush).
flex_context = {**(parent_asset.flex_context or {}), **flex_context}
parent_asset = parent_asset.parent_asset
return flex_context

Expand Down
9 changes: 9 additions & 0 deletions flexmeasures/data/models/planning/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ class Scheduler:
flex_model: list[dict] | dict | None = None
flex_context: dict | None = None
stock_groups: dict | None = None
#: Typed classification of the flex config (see planning.devices.DeviceInventory);
#: derived state, (re)built when the flex config is deserialized.
Comment thread
Flix6x marked this conversation as resolved.
device_inventory = None

fallback_scheduler_class: "Type[Scheduler] | None" = None
info: dict | None = None
Expand All @@ -71,6 +74,12 @@ class Scheduler:
def _build_stock_groups(flex_model: list[dict]) -> dict:
"""
Build stock groups where devices sharing the same state-of-charge sensor are grouped together.

Deprecated: use ``DeviceInventory.stock_groups`` (see ``planning.devices``),
which classifies flex-model entries once and keeps stock-group keys in sync
with the stock parameters. Note that this function's synthetic keys (for
devices without a state-of-charge sensor) depend on the length of the passed
list, so they only match ``stock_models`` keys built from the same list.
"""
groups = defaultdict(list)
soc_usage = defaultdict(list)
Expand Down
Loading
Loading