Skip to content

Expose operational mode through individual properties - #291

Merged
llucax merged 3 commits into
frequenz-floss:v0.x.xfrom
llucax:operational-mode
Jul 22, 2026
Merged

Expose operational mode through individual properties#291
llucax merged 3 commits into
frequenz-floss:v0.x.xfrom
llucax:operational-mode

Conversation

@llucax

@llucax llucax commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Using the operational mode protobuf enum as a component attribute is not very convenient. Users would need to check for multiple combinations to find out whether telemetry or control is available, plus handle the unspecified value, which should be rare but is possible.

Instead, keep the operational mode representation entirely in the protobuf conversion layer and expose it through two Component accessors that are much safer to use:

  • provides_telemetry(): whether the component provides telemetry data
  • accepts_control(): whether the component accepts control commands

Both raise ValueError when the operational mode is unspecified or unrecognized, so callers get an explicit failure instead of a silently wrong boolean. The mode is stored internally as two private bool | None fields that default to None (unspecified), so existing component construction sites remain unaffected.

This is a port of commit 5c729ba from frequenz-client-common, so we upgrade to it the migration should be smooth.

@llucax
llucax requested review from a team as code owners July 22, 2026 10:48
@llucax
llucax requested review from ela-kotulska-frequenz and hannah-stevenson-frequenz and removed request for a team July 22, 2026 10:48
@github-actions github-actions Bot added part:tests Affects the unit, integration and performance (benchmarks) tests part:tooling Affects the development tooling (CI, deployment, dependency management, etc.) labels Jul 22, 2026
@llucax llucax self-assigned this Jul 22, 2026
@llucax
llucax requested a review from shsms July 22, 2026 10:48
@llucax llucax added type:enhancement New feature or enhancement visitble to users part:client Affects the client code labels Jul 22, 2026
@llucax llucax added this to the v0.18.4 milestone Jul 22, 2026
llucax added 3 commits July 22, 2026 12:50
The operational mode field and the ElectricalComponentOperationalMode
enum were added to the ElectricalComponent protobuf message in
frequenz-api-common v0.8.3, but the enum value
ELECTRICAL_COMPONENT_OPERATIONAL_MODE_TELEMETRY_ONLY was misspelled
(TELEMTRY) in that release and only corrected in v0.8.4. The client now
reads that field and references the enum by name, so require v0.8.4 as
the minimum version.

Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
Using the operational mode protobuf enum as a component attribute is not
very convenient. Users would need to check for multiple combinations to
find out whether telemetry or control is available, plus handle the
unspecified value, which should be rare but is possible.

Instead, keep the operational mode representation entirely in the
protobuf conversion layer and expose it through two Component accessors
that are much safer to use:

- `provides_telemetry()`: whether the component provides telemetry data
- `accepts_control()`: whether the component accepts control commands

Both raise `ValueError` when the operational mode is unspecified or
unrecognized, so callers get an explicit failure instead of a silently
wrong boolean. The mode is stored internally as two private
`bool | None` fields that default to `None` (unspecified), so existing
component construction sites remain unaffected.

This is a port of commit [5c729ba][] from `frequenz-client-common`, so
we upgrade to it the migration should be smooth.

[5c729ba]: frequenz-floss/frequenz-client-common-python@5c729ba

Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
@llucax
llucax force-pushed the operational-mode branch from ab194cc to 3ca46c0 Compare July 22, 2026 10:50
@github-actions github-actions Bot added the part:docs Affects the documentation label Jul 22, 2026
@llucax
llucax enabled auto-merge July 22, 2026 10:52

@shsms shsms 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.

🎉

@llucax
llucax added this pull request to the merge queue Jul 22, 2026
@llucax

llucax commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

One thing to have is mind is that these methods raise a built-in ValueError if something is wrong, while the ones in client-common raise a specialized exception. I thought porting the whole exception hierarchy was too much, and the specialized exception is also a subclass of ValueError, so catching ValueError now should keep working in the future.

Merged via the queue into frequenz-floss:v0.x.x with commit f592b08 Jul 22, 2026
9 checks passed
@llucax
llucax deleted the operational-mode branch July 22, 2026 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

part:client Affects the client code 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.) type:enhancement New feature or enhancement visitble to users

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants