Skip to content

Update the component graph to v0.5.0#111

Merged
shsms merged 5 commits into
frequenz-floss:v0.x.xfrom
shsms:update-component-graph-0.5
Jul 20, 2026
Merged

Update the component graph to v0.5.0#111
shsms merged 5 commits into
frequenz-floss:v0.x.xfrom
shsms:update-component-graph-0.5

Conversation

@shsms

@shsms shsms commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

The component graph library v0.5.0 changes the default source order of the
per-category formulas, and gridpool offered no way to configure the graph.
This branch takes the update and exposes the graph configuration.

Changes

  • Update frequenz-microgrid-component-graph to v0.5.0. The per-category
    formulas (pv, battery, chp, ev) now read the component first and
    fall back to the meter, which changes the generated config.
  • load_configs and load_configs_from_api take a component_graph_config
    argument, and ComponentGraphGenerator takes it as config;
    ComponentGraphConfig and FormulaOverrides are re-exported.
  • generate-config and print-formulas take a
    --prefer-meters-in-component-formulas flag to keep the old meter-first
    order.
  • Fix the dev-pytest extra to pull render-graph, so mypy and the 11
    render-graph tests actually run.

Breaking

  • The default per-category formula order flips to component-first; regenerate
    stored configs and review the diff, or pass
    ComponentGraphConfig(prefer_meters_in_component_formulas=True) /
    --prefer-meters-in-component-formulas to keep the old order.

shsms added 5 commits July 20, 2026 12:58
dev-pytest pulled only the cli extra, so matplotlib and networkx were
missing. mypy could not find the matplotlib stubs and failed on
_render_graph.py, and pytest skipped tests/test_render_graph.py, so its
11 tests never ran.

Pull the render-graph extra instead, which already includes cli.

Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
v0.5.0 flips the default of prefer_meters_in_component_formulas to
False, so the per-category formulas now read the component first and
use the meter as the fallback. We take the new default, which changes
the per-category formulas in the generated config.

The test graph only has a solar inverter, so the pinned pv formulas
flip their expected order.

Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
The graph was built with no ComponentGraphConfig, so callers had no way
to change the source order or any other graph setting. In particular
they could not keep the meter-first per-category formulas that v0.5.0 of
the component graph library moved away from.

Take an optional config in ComponentGraphGenerator and thread it through
load_configs_from_api and load_configs. Re-export ComponentGraphConfig
and FormulaOverrides from frequenz.gridpool and frequenz.gridpool.config
so callers do not have to import them from the library.

load_configs raises when the config is given without an assets_client,
the same way it already does for microgrid_ids, so a config that could
never be applied is an error rather than a silent no-op.

The default is unchanged: with no config the library's own defaults
apply.

Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
The config knob was only reachable from Python, but generate-config is
the tool that regenerates stored configs. An operator who wanted to keep
the meter-first order had to write a script instead.

The generate-config and print-formulas commands now take
--prefer-meters-in-component-formulas, which builds a
ComponentGraphConfig with prefer_meters_in_component_formulas set.
Without the flag no config is passed, so the defaults still apply.

Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
@shsms
shsms requested review from a team as code owners July 20, 2026 14:59
@shsms
shsms requested review from Linus404 and ela-kotulska-frequenz and removed request for a team July 20, 2026 14:59
@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.) labels Jul 20, 2026
@shsms
shsms force-pushed the update-component-graph-0.5 branch 2 times, most recently from 8a280d4 to 8d3027b Compare July 20, 2026 15:08
@shsms
shsms added this pull request to the merge queue Jul 20, 2026
Merged via the queue into frequenz-floss:v0.x.x with commit 0a1ee9a Jul 20, 2026
9 checks passed
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:tests Affects the unit, integration and performance (benchmarks) tests part:tooling Affects the development tooling (CI, deployment, dependency management, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants