Skip to content

Commit a6d0d2b

Browse files
committed
Expose steam_boiler_formula on the Python bindings
The upstream cg crate gained `ComponentGraph::steam_boiler_formula` in 0.5 (alongside the new `SteamBoiler` component category), but the Python bindings never wired it up. Adds the binding and the matching stub. Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
1 parent 56360ad commit a6d0d2b

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

python/frequenz/microgrid_component_graph/__init__.pyi

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,22 @@ class ComponentGraph(Generic[ComponentT, ConnectionT, ComponentIdT]):
360360
are not wind turbines.
361361
"""
362362

363+
def steam_boiler_formula(self, steam_boiler_ids: Set[ComponentIdT] | None) -> str:
364+
"""Generate the steam boiler formula for this component graph.
365+
366+
Args:
367+
steam_boiler_ids: The set of steam boiler component IDs to include in
368+
the formula. If `None`, all steam boilers in the graph will be
369+
included.
370+
371+
Returns:
372+
The steam boiler formula as a string.
373+
374+
Raises:
375+
FormulaGenerationError: if the given component IDs don't exist or
376+
are not steam boilers.
377+
"""
378+
363379
def grid_coalesce_formula(self) -> str:
364380
"""Generate the grid coalesce formula for this component graph.
365381

src/graph.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,18 @@ impl ComponentGraph {
352352
.map_err(|e| PyErr::new::<FormulaGenerationError, _>(e.to_string()))
353353
}
354354

355+
#[pyo3(signature = (steam_boiler_ids=None))]
356+
fn steam_boiler_formula(
357+
&self,
358+
py: Python<'_>,
359+
steam_boiler_ids: Option<Bound<'_, PyAny>>,
360+
) -> PyResult<String> {
361+
self.graph
362+
.steam_boiler_formula(extract_ids(py, steam_boiler_ids)?)
363+
.map(|f| f.to_string())
364+
.map_err(|e| PyErr::new::<FormulaGenerationError, _>(e.to_string()))
365+
}
366+
355367
fn grid_coalesce_formula(&self) -> PyResult<String> {
356368
self.graph
357369
.grid_coalesce_formula()

0 commit comments

Comments
 (0)