Skip to content

Update the microgrid component graph to v0.5.0 and make it configurable#1437

Open
shsms wants to merge 3 commits into
frequenz-floss:v1.x.xfrom
shsms:component-graph-0.5
Open

Update the microgrid component graph to v0.5.0 and make it configurable#1437
shsms wants to merge 3 commits into
frequenz-floss:v1.x.xfrom
shsms:component-graph-0.5

Conversation

@shsms

@shsms shsms commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

The microgrid component graph library v0.5.0 changes the per-category
formulas to read the components first and use the meter as the fallback.
This PR upgrades the SDK to it and lets applications configure the
component graph from the top-level API.

Changes

  • Update frequenz-microgrid-component-graph to >= 0.5.0, < 0.6.
  • Add a component_graph_config keyword argument to
    microgrid.initialize(). It takes a ComponentGraphConfig, which is
    passed to the ComponentGraph constructor. ComponentGraphConfig and
    FormulaOverrides are re-exported from frequenz.sdk.microgrid.
  • Update the formula tests to send component values that differ from the
    meter values, so both the new component-first order and the meter
    fallback are verified at runtime.
  • Rename the test helper ComponentGraphConfig to ComponentGraphSpec,
    to avoid confusion with the re-exported library class.

Breaking

  • Per-category formulas (battery, PV, CHP, EV charger, ...) now read the
    components first and use the meter as the fallback. Pass
    ComponentGraphConfig(prefer_meters_in_component_formulas=True) to
    microgrid.initialize() to restore the old order.
  • Generated formula strings can differ from the previous release, and
    graph validation errors use the new Graph validation failed: message
    format.

shsms added 3 commits July 17, 2026 14:24
The name clashes with the `ComponentGraphConfig` class of the
component graph library, which a later commit re-exports from
`frequenz.sdk.microgrid`.

Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
The new version generates formulas that read from the components
first and use the meter as the fallback.  Some tests only sent meter
values, so the formula engines never produced a value and the tests
hung.  These tests now also send component values.  One test also
asserts the exact formula string, which now has the new COALESCE
order.

Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
The new `component_graph_config` keyword argument takes a
`ComponentGraphConfig` and is passed to the `ComponentGraph`
constructor.  When it is `None`, the library's default configuration
is used.  `ComponentGraphConfig` and `FormulaOverrides` are
re-exported from `frequenz.sdk.microgrid`.

Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
@shsms
shsms requested a review from a team as a code owner July 17, 2026 14:51
@shsms
shsms requested review from ela-kotulska-frequenz and removed request for a team July 17, 2026 14:51
@github-actions github-actions Bot added part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests part:tooling Affects the development tooling (CI, deployment, dependency management, etc.) part:microgrid Affects the interactions with the microgrid labels Jul 17, 2026
@shsms
shsms force-pushed the component-graph-0.5 branch from 4ece16b to 183c5ed Compare July 17, 2026 15:03

@daniel-zullo-frequenz daniel-zullo-frequenz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM code-wise.

Should the release notes mention more explicit about the braking change described in the PR description?

Per-category formulas (battery, PV, CHP, EV charger, ...) now read the components first and use the meter as the fallback. Pass ComponentGraphConfig(prefer_meters_in_component_formulas=True) to
microgrid.initialize() to restore the old order.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

part:docs Affects the documentation part:microgrid Affects the interactions with the microgrid part:tests Affects the unit, integration and performance (benchmarks) tests part:tooling Affects the development tooling (CI, deployment, dependency management, etc.)

Projects

Status: To do

Development

Successfully merging this pull request may close these issues.

2 participants