bloc.boulder_plugins.sweep_kpis#

Per-scenario sweep hooks: KPI attrs for the plot, cache write for export.

Registered as plugins.scenario_attrs / plugins.on_scenario_solved in bloc.boulder_plugins.register. Both fire on Boulder’s own sweep code (boulder.sweep_runner and the GUI’s in-process boulder.api.routes.sweep) — no Bloc-specific sweep runner needed.

Input parameters (e.g. a node’s declared pressure) don’t need a hook at all — Boulder auto-walks every node/connection’s numeric properties on its own (see boulder.runset.node_property_attrs). This module only supplies genuinely computed KPIs, which Boulder has no way to derive itself.

Attributes#

Functions#

scenario_attrs(scenario_id, merged_config, gui_payload)

KPI attrs the Sweep Results plot can offer as X/Y axes.

on_scenario_solved(scenario_id, config, converter, ...)

Write this scenario's calc-note artifacts beside its stored result.

Module Contents#

bloc.boulder_plugins.sweep_kpis.logger#
bloc.boulder_plugins.sweep_kpis.scenario_attrs(scenario_id, merged_config, gui_payload)#

KPI attrs the Sweep Results plot can offer as X/Y axes.

Every model-level KPI already on the summary payload is offered: the rows a model’s export.kpi_fn produced (see bloc.boulder_plugins.kpi_summary_pane) carry the KPI key as quantity and its unit, which is exactly what an axis needs, as do the rows BlocConverter._inject_spring_performance_summary files under the synthetic “Performance” reactor.

Rows belonging to a real reactor are skipped: they name a property, not a KPI, their keys repeat across reactors and would collide, and Boulder already auto-walks node properties itself (boulder.runset.node_property_attrs).

carbon_yield stays published under that name as well, since SPRING-family sweeps and saved plots refer to it. Its display unit comes from bloc.io.scenario.OUTPUT_VARIABLE_MAP, the same map the Calculation Note uses — one source of truth, not a literal here.

bloc.boulder_plugins.sweep_kpis.on_scenario_solved(scenario_id, config, converter, simulation_result, fingerprint, gui_payload, mechanism)#

Write this scenario’s calc-note artifacts beside its stored result.

Boulder’s sweep already stores the result – one store, keyed by scenario name – so nothing here needs to persist a payload any more. What is still ours is the artifacts: running the registered cache contributors against the entry Boulder just wrote, so “Export Calculation Note” finds a bundle for every swept scenario instead of re-solving it.

(Boulder runs contributors on a single-run solve but not inside its sweep loop, which is the only reason this hook still exists. If it ever does – it has the store dir and the scenario id right there – this can go.)