Skip to content

Read the operational mode from Python components - #99

Merged
shsms merged 3 commits into
frequenz-floss:v0.x.xfrom
shsms:component-graph-0.6.1
Aug 27, 2026
Merged

shsms merged 3 commits into
frequenz-floss:v0.x.xfrom
shsms:component-graph-0.6.1

Conversation

@shsms

@shsms shsms commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

frequenz-microgrid-component-graph v0.6.1 adds an operational mode to graph
components, but the trait default leaves every component Unspecified — the
bindings have to read the mode off each Python component for it to have any
effect. This builds against v0.6.1, translates the mode, and releases 0.5.1.

Changes

  • Bump the crate from v0.6.0 to v0.6.1.
  • Translate provides_telemetry() / accepts_control() into one
    OperationalMode in Component::try_new, alongside the existing category
    translation.
  • Raise the microgrid extra's floor to frequenz-client-microgrid >= 0.18.4,
    the release the two methods arrived in. On 0.18.3 the mode is never readable
    and the new tests cannot run.
  • Write the release notes and bump the version to 0.5.1.

Worth a look

  • Both flags or nothing. A mode is named only when both are known:
    provides_telemetry() == false fits Inactive and ControlOnly alike, so a
    half-known mode stays Unspecified rather than being guessed at.
  • Missing accessors are tolerated. The assets client has no equivalent
    methods, so their absence reads as unspecified instead of failing the graph —
    the same tolerance the category lookup already has.
  • getattr and call0 are separate steps so a missing method reads as
    unspecified while an AttributeError from inside the method body propagates.
    call_method0 cannot tell those apart, and swallowing the second would hide a
    caller's bug and leave the component measuring.

@shsms
shsms requested a review from a team as a code owner July 28, 2026 09:39
@shsms
shsms requested review from florian-wagner-frequenz and removed request for a team July 28, 2026 09:39
@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 28, 2026
Comment thread tests/test_microgrid_component_graph.py
unspecified mode. It is treated as providing telemetry, so graphs that
never set a mode keep their formulas.
"""
graph = _pv_graph_with_modes(provides_telemetry=None, accepts_control=None)

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.

Small warning. I changed this in client-common to use bool | int instead of bool | None so we can also represent a new enum value (I think it will be extremely unlikely that we get one, but still, to match the style we use for other enums), and 0 represents unspecified, so this code will need a small update when moving to client-common (but I guess it will require many more updates anyway).

Comment thread src/component.rs
shsms added 3 commits August 27, 2026 10:51
This adds support for using the operational mode of components in
formula generation.  It also includes a number of bug fixes.

Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
Translate the operational mode the way the category is translated:
Python splits the mode into `provides_telemetry()` and
`accepts_control()`, and the two together name one `OperationalMode`.

A mode is named only when both flags are known -- `provides_telemetry()
== false` fits both `Inactive` and `ControlOnly` -- and a component may
lack the methods entirely, as the assets client does. Both cases read as
unspecified rather than failing the graph.

Raise the `microgrid` extra to `frequenz-client-microgrid >= 0.18.4`, the
release the two methods arrived in. On the old floor of 0.18.3 the mode
was never readable and the mode tests could not run.

Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
Bump the crate version to 0.5.1 and write the release summary. Drop the
empty Bug Fixes section, as CONTRIBUTING asks for at release time.

Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
@shsms
shsms force-pushed the component-graph-0.6.1 branch from c4f1af9 to 13a5afc Compare August 27, 2026 09:00
@shsms

shsms commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator Author

I've also updated to component-graph-rs 0.6.2, which includes the bug fixes we merged last.

@llucax llucax 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. I just don't get why is frequenz-client-microgrid a dependency at all, I don't see any imports for it in the repo.

Comment thread pyproject.toml
@shsms
shsms added this pull request to the merge queue Aug 27, 2026
Merged via the queue into frequenz-floss:v0.x.x with commit ca626df Aug 27, 2026
9 checks passed
@shsms
shsms deleted the component-graph-0.6.1 branch August 27, 2026 16:54
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