Pass-through component support in the Python bindings#49
Draft
shsms wants to merge 5 commits intofrequenz-floss:v0.x.xfrom
Draft
Pass-through component support in the Python bindings#49shsms wants to merge 5 commits intofrequenz-floss:v0.x.xfrom
shsms wants to merge 5 commits intofrequenz-floss:v0.x.xfrom
Conversation
`category_from_python_component` now recognises six additional classes from `frequenz-client-microgrid` that correspond to the Rust crate's pass-through categories: Converter, Precharger, Electrolyzer, Hvac, CryptoMiner (1:1 names) VoltageTransformer → cg::ComponentCategory::PowerTransformer The last one is a name mismatch the upstream client and the Rust enum carry from before this work — there's no `PowerTransformer` class on the Python side and no `VoltageTransformer` variant on the Rust side, so the mapping crosses the gap. Adds a `test_passthrough_voltage_transformer` end-to-end test: builds `Grid → VoltageTransformer → Meter → SolarInverter`, verifies the graph constructs (the validator walks past the transformer when checking the meter's predecessor), and asserts that `predecessors` / `successors` skip it. The next commit extends the test to also cover `raw_predecessors` / `raw_successors` once those are exposed. Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
Wraps the Rust crate's `raw_predecessors` and `raw_successors` methods on the pyclass so Python callers can ask for the unfiltered, graph-direct view of a node's neighbors (the one that includes pass-through nodes), as a counterpart to the now-pass-through-aware `predecessors` and `successors`. Updates the type stubs to declare both pairs of methods and document which is which. Extends the `test_passthrough_voltage_transformer` test from the previous commits with assertions on the new `raw_*` methods, exposing the pass-through that the effective view skips. Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
The four pyclass methods that wrap the Rust crate's `predecessors` / `successors` / `raw_predecessors` / `raw_successors` had near-identical bodies: extract the component id, dispatch to the rust method, map the error onto `ValueError`, and build a `PySet` from the yielded `&Component`s. Pull that boilerplate into a private `neighbors_set` free function so each method shrinks to a single delegating call. Pure refactor; no behavior or API change. Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
The upstream `frequenz-client-microgrid` client publishes a `Relay` class, but internally it carries the protobuf `ELECTRICAL_COMPONENT_CATEGORY_BREAKER` value (see `_category.py`'s `RELAY = ELECTRICAL_COMPONENT_CATEGORY_BREAKER`). The Rust crate doesn't have a separate `Relay` variant either — `Breaker` covers both, so the mapping lands there to match the upstream protobuf source of truth. Like the other pass-through mappings added two commits ago, `Relay` becomes transparent to validators and formula generators. Extends the `test_passthrough_category_recognized` parametrize list with `Relay` so the new arm is exercised. The Python-side cleanup to expose `Breaker` directly instead of carrying the `Relay` alias is left for a follow-up. Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
Local Cargo overrides (e.g. `[paths]` in `.cargo/config.toml`) shouldn't be checked in — they're per-developer, used to point this crate at sibling local repos during cross-repo development. Adds the directory to .gitignore so the clutter stays out of `git status`. Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Updates the bindings to support the feature to treat unknown categories as pass-through in the rust implementation: frequenz-floss/frequenz-microgrid-component-graph-rs#35