bloc.reporting.orchestrator_stone#
STONE backend for Calculation Note generation.
Functions#
|
Collect inputs, outputs, metadata and figures for one STONE scenario. |
|
Generate a Calculation Note Excel from pre-collected scenario bundles. |
|
Run STONE scenarios and generate Calculation Note Excel. |
Module Contents#
- bloc.reporting.orchestrator_stone.collect_scenario_bundle(scenario_id, sim, metadata, export_config, out_dir, yaml_path=None, kpi_fn=None)#
Collect inputs, outputs, metadata and figures for one STONE scenario.
Wraps
_collect_scenario_stone()and returns the collected data as a(bundle, diagram_paths)tuple suitable for caching. The caller is responsible for serialising the result to disk.- Parameters:
scenario_id – String identifier for this scenario (used as dict key and filename prefix).
sim – Solved
Simulationwith live Cantera objects.metadata – Scenario metadata dict (from the YAML
metadata:block).export_config – Resolved
export:block from the YAML.out_dir – Directory where figure files may be written.
yaml_path – Optional path to the source YAML (used for provenance in the bundle).
kpi_fn – Optional
kpi_fn(sim) -> dictcallable for domain-specific KPIs.
- Returns:
(bundle, diagram_paths)where bundle is the scenario dict (inputs,outputs,node_data,energy_flows, etc.) and diagram_paths maps figure names to their on-diskPathobjects.- Return type:
tuple[dict,dict]
- bloc.reporting.orchestrator_stone.generate_calculation_note_stone_from_bundles(scenario_results, diagram_paths, out_dir, base_dir=None, calc_note_name='Calculation_Note.xlsx', title='STONE Calculation Note', subtitle='Generated by Bloc (STONE / Boulder)', all_yaml_files=None, all_header_comments=None, export_config=None)#
Generate a Calculation Note Excel from pre-collected scenario bundles.
Skips the simulation step by reusing data collected by
collect_scenario_bundle()(stored in the cache entry’sartifacts/directory). All arguments map directly to_finalize_calculation_note_excel().- Parameters:
scenario_results – Mapping
{scenario_id: bundle_dict}as returned bycollect_scenario_bundle().diagram_paths – Mapping
{scenario_id: {fig_name: Path}}as returned bycollect_scenario_bundle().out_dir – Directory where the Excel file is written.
base_dir – Base directory for relative path resolution (defaults to out_dir).
calc_note_name – Output Excel filename.
title – Workbook title string.
subtitle – Workbook subtitle string.
all_yaml_files – List of YAML filenames recorded in the workbook provenance tab.
all_header_comments – List of header comment strings from source YAML files.
export_config – Resolved
export:block; used for variable-map resolution.
- Returns:
Path to the generated Excel file, or None on failure.
- Return type:
PathorNone
- bloc.reporting.orchestrator_stone.generate_calculation_note_stone(base_yaml, output_dir='Results', extra_yamls=None, scenario_yamls=None, include_base=True, validate_strict=False, kpi_fn=None)#
Run STONE scenarios and generate Calculation Note Excel.
Uses
bloc.io.boulder_bridge.build_simulation_from_yaml()for each scenario (base + overlays). Validates YAML withvalidate_yaml_file()(no strict unit check for STONE). Writes the same Excel format asgenerate_calculation_note().- Parameters:
base_yaml (
strorPath) – Path to the base STONE YAML (e.g. SPRING_A3_BG_20260212_stone.yaml).output_dir (
str) – Output directory relative to the YAML parent.extra_yamls (
strorlist[str]orNone) – Glob pattern(s) for overlay STONE YAMLs (e.g. “_stone.yaml”). Deprecated — prefer declaring variations inline in the base YAML viascenarios:orsweeps:(seebloc.yaml_utils.expand_scenarios()). Combining inline scenarios withextra_yamlsis rejected.scenario_yamls (
strorlist[str]orNone) – Standalone scenario YAML files/patterns to run and aggregate into the same workbook. Supports files usingfrom: master.yamlinheritance. Unlikeextra_yamls, these files are not deep-merged ontobase_yaml; each is treated as a complete scenario definition.include_base (
bool) – If True, run the base YAML as a scenario in addition to inline/standalone scenarios. If False, base is used only as workbook/export template.validate_strict (
bool) – If True, raise on any YAML validation issue.kpi_fn (
callableorNone) – Optionalkpi_fn(sim) -> dictthat computes domain-specific KPIs from each solvedSimulation. Its output is merged into theoutputscolumn of the Calculation Note. Equivalent to settingexport.kpi_fn: "module:attr"in the YAML; specifying both is ambiguous and raisesValueError. Usebloc.reporting.spring_kpi.compute_spring_kpis()for SPRING architectures.
Notes
The STONE
export:block also accepts:kpi_fn— dotted path ("module:attr") resolved viabloc.yaml_utils.resolve_dotted().figures— list of keys intobloc.yaml_utils.STONE_FIGURE_GENERATORS. Each generator has signature(sim, out_dir) -> dict[str, str].
- Returns:
Path to the generated Excel file, or None if base YAML has no metadata.
- Return type:
PathorNone