Release Notes
Summary
The main feature in the release is the high-level interface. Now all base pipeline actors are created automatically when the SDK is initialized, and the wrapper classes can be accessed directly via `frequenz.sdk.microgrid`: `logical_meter()`, `battery_pool()` and `ev_charger_pool()`.
Upgrading
* Battery power is no longer available through the `LogicalMeter`, but through the `BatteryPool` (338)
python
battery_power_receiver = microgrid.battery_pool().power.new_receiver()
* Formulas composition has changed (327)
* Receivers from formulas are no longer composable.
* Formula composition is now done by composing FormulaEngine instances.
* Automatic formulas from the logical meter and \*pools, are now properties, and return `FormulaEngine` instances, which can be composed further, or can provide a receiver to fetch values.
python
grid_power_receiver = microgrid.logical_meter().grid_power.new_receiver()
self._inverter_power = (
microgrid.logical_meter().pv_power
+ microgrid.battery_pool().power
).build("inverter_power")
inverter_power_receiver = self._inverter_power.new_receiver()
* Update `BatteryStatus` to mark battery with unknown capacity as not working (263)
* The channels dependency was updated to v0.14.0 (292)
* Some properties for `PowerDistributingActor` results were renamed to be more consistent between `Success` and `PartialFailure`:
* The `Success.used_batteries` property was renamed to `succeeded_batteries`.
* The `PartialFailure.success_batteries` property was renamed to `succeeded_batteries`.
* The `succeed_power` property was renamed to `succeeded_power` for both `Success` and `PartialFailure`.
* `MovingWindow`
* The class is now publicly available in the `frequenz.sdk.timeseries` package.
* Accept the `size` parameter as `timedelta` instead of `int` (269).
This change allows users to define the time span of the moving window more intuitively, representing the duration over which samples will be stored.
* The input data will be resampled if a `resampler_config` is passed (269).
This allows controlling the granularity of the samples to be stored in the underlying buffer.
Note that the parameter `sampling_period` has been renamed to `input_sampling_period` to better distinguish it from the sampling period parameter in the `resampler_config`.
* Rename the constructor argument `window_alignment` to `align_to` and change the default to `UNIX_EPOCH`. This is to make it more consistent with the `ResamplerConfig`.
* `Resampler`
* The `ResamplerConfig` class is now publicly available in the `frequenz.sdk.timeseries` package.
* The `ResamplerConfig` now takes the resampling period as a `timedelta`. The configuration was renamed from `resampling_period_s` to `resampling_period` accordingly.
* The `SourceProperties` of the resampler now uses a `timedelta` for the input sampling period. The attribute was renamed from `sampling_period_s` to `sampling_period` accordingly.
* The periods are now aligned to the `UNIX_EPOCH` by default.
To use the old behaviour (aligning to the time the resampler was created), pass `align_to=None` to the `ResamplerConfig`.
New Features
* The core data-pipeline actors are now created automatically (270).
This eliminates a lot of boiler plate code and makes it much simpler to deploy apps.
For example:
python
async def run():
await microgrid.initialize(
host=HOST, port=PORT, resampler_config=ResamplerConfig(resampling_period_s=1.0)
)
grid_power = microgrid.logical_meter().grid_power()
* The `Result` class (and subclasses) for the `PowerDistributingActor` are now `dataclass`es, so logging them will produce a more detailed output.
* The `Resampler` can now can align the resampling period to an arbitrary `datetime`.
This can be configured via the new `align_to` option in the `ResamplerConfig`. By default the resampling period is aligned to the `UNIX_EPOCH`.
Bug Fixes
* Change `PowerDistributor` to use all batteries when none are working (258)
* Update the ordered ring buffer used by the `MovingWindow` to fix the `len()` function so that it returns a value equal to or greater than zero, as expected (274)
What's Changed
* Power Distributing: Documentation enhancements by mathias-baumann-frequenz in https://github.com/frequenz-floss/frequenz-sdk-python/pull/257
* Clean release notes by ela-kotulska-frequenz in https://github.com/frequenz-floss/frequenz-sdk-python/pull/271
* Check battery capacity in BatteryStatus by ela-kotulska-frequenz in https://github.com/frequenz-floss/frequenz-sdk-python/pull/263
* Use all batteries when none are working in PowerDistributor by ela-kotulska-frequenz in https://github.com/frequenz-floss/frequenz-sdk-python/pull/258
* Configure dependabot to automated version updates by daniel-zullo-frequenz in https://github.com/frequenz-floss/frequenz-sdk-python/pull/268
* Bump pylint from 2.17.0 to 2.17.1 by dependabot in https://github.com/frequenz-floss/frequenz-sdk-python/pull/288
* Bump mypy from 1.0.1 to 1.1.1 by dependabot in https://github.com/frequenz-floss/frequenz-sdk-python/pull/286
* Bump actions/labeler from 4.0.1 to 4.0.3 by dependabot in https://github.com/frequenz-floss/frequenz-sdk-python/pull/279
* Bump pytest from 7.2.1 to 7.2.2 by dependabot in https://github.com/frequenz-floss/frequenz-sdk-python/pull/287
* Bump black from 23.1.0 to 23.3.0 by dependabot in https://github.com/frequenz-floss/frequenz-sdk-python/pull/284
* Update channels dependency to v0.14.0 by mathias-baumann-frequenz in https://github.com/frequenz-floss/frequenz-sdk-python/pull/295
* Various small fixes by mathias-baumann-frequenz in https://github.com/frequenz-floss/frequenz-sdk-python/pull/277
* Fix len() of the OrderedRingBuffer by daniel-zullo-frequenz in https://github.com/frequenz-floss/frequenz-sdk-python/pull/274
* Bump pytest-asyncio from 0.20.3 to 0.21.0 by dependabot in https://github.com/frequenz-floss/frequenz-sdk-python/pull/281
* Bump mkdocstrings[python] from 0.19.1 to 0.20.0 by dependabot in https://github.com/frequenz-floss/frequenz-sdk-python/pull/283
* Update networkx requirement from <3,>=2.8 to >=2.8,<4 by dependabot in https://github.com/frequenz-floss/frequenz-sdk-python/pull/282
* Bump mkdocs-material from 8.5.11 to 9.1.5 by dependabot in https://github.com/frequenz-floss/frequenz-sdk-python/pull/298
* Add a `DataPipeline` implementation by shsms in https://github.com/frequenz-floss/frequenz-sdk-python/pull/270
* Bump pylint from 2.17.1 to 2.17.2 by dependabot in https://github.com/frequenz-floss/frequenz-sdk-python/pull/300
* Use a bigger request receiver buffer size in data pipeline actors by shsms in https://github.com/frequenz-floss/frequenz-sdk-python/pull/302
* Refactor power distributor's `Result`s by leandro-lucarella-frequenz in https://github.com/frequenz-floss/frequenz-sdk-python/pull/305
* Bump mkdocstrings[python] from 0.20.0 to 0.21.1 by dependabot in https://github.com/frequenz-floss/frequenz-sdk-python/pull/308
* Add `component_data` method to EVChargerPool by shsms in https://github.com/frequenz-floss/frequenz-sdk-python/pull/266
* benchmark data sourcing actor by mathias-baumann-frequenz in https://github.com/frequenz-floss/frequenz-sdk-python/pull/211
* Add ringbuffer memory benchmark by mathias-baumann-frequenz in https://github.com/frequenz-floss/frequenz-sdk-python/pull/278
* Update MovingWindow to add resampler by daniel-zullo-frequenz in https://github.com/frequenz-floss/frequenz-sdk-python/pull/272
* Bump mkdocs-material from 9.1.5 to 9.1.6 by dependabot in https://github.com/frequenz-floss/frequenz-sdk-python/pull/312
* Add a `EVChargerPool.set_bounds` method for setting current bounds by shsms in https://github.com/frequenz-floss/frequenz-sdk-python/pull/297
* Bump mkdocstrings[python] from 0.21.1 to 0.21.2 by dependabot in https://github.com/frequenz-floss/frequenz-sdk-python/pull/309
* Bump pytest from 7.2.2 to 7.3.0 by dependabot in https://github.com/frequenz-floss/frequenz-sdk-python/pull/313
* Bump mypy from 1.1.1 to 1.2.0 by dependabot in https://github.com/frequenz-floss/frequenz-sdk-python/pull/310
* Add BatteryPool and PowerDistributingActor to the DataPipeline by sahas-subramanian-frequenz in https://github.com/frequenz-floss/frequenz-sdk-python/pull/317
* Expose BatteryPool and PowerDistributingHandle from `sdk.microgrid` by sahas-subramanian-frequenz in https://github.com/frequenz-floss/frequenz-sdk-python/pull/323
* Fix ring buffer benchmarks by daniel-zullo-frequenz in https://github.com/frequenz-floss/frequenz-sdk-python/pull/324
* Make interface for serializing a ringbuffer more flexible. by mathias-baumann-frequenz in https://github.com/frequenz-floss/frequenz-sdk-python/pull/326
* Ringbuffer: Moved files into a package by mathias-baumann-frequenz in https://github.com/frequenz-floss/frequenz-sdk-python/pull/329
* Update `BatteryPool` tests, examples to use `microgrid.battery_pool()` by sahas-subramanian-frequenz in https://github.com/frequenz-floss/frequenz-sdk-python/pull/336
* Bump pytest from 7.3.0 to 7.3.1 by dependabot in https://github.com/frequenz-floss/frequenz-sdk-python/pull/339
* Make the resampler use timedelta for periods by leandro-lucarella-frequenz in https://github.com/frequenz-floss/frequenz-sdk-python/pull/334
* Bump frequenz-floss/setup-git-user from 1 to 2 by dependabot in https://github.com/frequenz-floss/frequenz-sdk-python/pull/345
* Make FormulaEngine instances composable, instead of FormulaReceivers by sahas-subramanian-frequenz in https://github.com/frequenz-floss/frequenz-sdk-python/pull/327
* Add `power` formula to `BatteryPool` by sahas-subramanian-frequenz in https://github.com/frequenz-floss/frequenz-sdk-python/pull/338
* Add an option to align resampling windows by leandro-lucarella-frequenz in https://github.com/frequenz-floss/frequenz-sdk-python/pull/335
* Increase sample_rate in some formula tests to reduce flakiness by sahas-subramanian-frequenz in https://github.com/frequenz-floss/frequenz-sdk-python/pull/351
* Bump mkdocs-material from 9.1.6 to 9.1.7 by dependabot in https://github.com/frequenz-floss/frequenz-sdk-python/pull/353
* Bump nox from 2022.11.21 to 2023.4.22 by dependabot in https://github.com/frequenz-floss/frequenz-sdk-python/pull/354
* Rename custom loggers to `_logger` by sahas-subramanian-frequenz in https://github.com/frequenz-floss/frequenz-sdk-python/pull/347
* Rename alignment arguments to `align_to` and make them default to `UNIX_EPOCH` by leandro-lucarella-frequenz in https://github.com/frequenz-floss/frequenz-sdk-python/pull/349
* Make the `MovingWindow` public and remove public mentions to the `RingBuffer` by leandro-lucarella-frequenz in https://github.com/frequenz-floss/frequenz-sdk-python/pull/355
* Bump mkdocs-material from 9.1.7 to 9.1.8 by dependabot in https://github.com/frequenz-floss/frequenz-sdk-python/pull/357
* Bump pylint from 2.17.2 to 2.17.3 by dependabot in https://github.com/frequenz-floss/frequenz-sdk-python/pull/356
New Contributors
* dependabot made their first contribution in https://github.com/frequenz-floss/frequenz-sdk-python/pull/288
**Full Changelog**: https://github.com/frequenz-floss/frequenz-sdk-python/compare/v0.19.0...v0.20.0