API Reference¶
Package Exports¶
Top-level exports from r2x_sienna:
SiennaConfigSiennaExporterConfigSiennaParserSiennaExporterSiennaUpgraderSiennaVersionDetector
Compatibility note:
The packaged
r2x_sienna.modelsdefinitions are maintained to match currentPowerSystems.jlschemas for overlapping model names, with backward-compatible aliases used where practical to avoid breaking existing inputs.
Parser¶
SiennaConfig¶
Main parse configuration fields:
model_year: int or list of intssystem_name: optional system labeljson_path: input JSON pathsystem_base_power: base MVA for per-unit calculationsscenario: scenario labelskip_validation: parsing validation togglemodels: model module tuple (default includesr2x_sienna.models)output_path: optional output path used by CLI/core pipeline integrations
The parser also supports input supplied by the core plugin context’s stdin
payload. When reading from disk, json_path is required and may point to a JSON
file or a directory containing the system JSON.
SiennaParser¶
Primary usage:
parser = SiennaParser.from_context(ctx)
result_ctx = parser.run()
system = result_ctx.system
Responsibilities:
Runs upgrades before build
Parses components and references
Restores supplemental attributes and associations
Connects time series storage metadata when present
Normalizes PSY field names and parametrized component metadata
Creates compatibility time series for hydro reservoir inflow and dispatch budgets
Lifecycle hooks:
on_prepare(): normalizes parser configuration and detects stdin input.on_upgrade(): invokesrun_sienna_upgrades(...)before deserialization.on_build(): creates theSystem, parses components, restores supplemental attributes, and configures time-series storage.
Use SiennaParser.from_context(ctx).run() rather than calling lifecycle hooks
directly. The result context contains the parsed system.
Exporter¶
SiennaExporterConfig¶
Main export configuration fields:
output_path: required output JSON pathsystem_base_power: base MVAscenario: scenario labelmodels: model module tuple
output_path is required by the exporter configuration. The exporter receives
the source System through PluginContext.system.
SiennaExporter¶
Primary usage:
exporter = SiennaExporter.from_context(export_ctx)
exporter.run()
Runtime behavior:
Serializes supported components to PSY-compatible dictionaries
Serializes supported supplemental attributes and associations
Writes JSON to
output_pathWrites HDF5 time series output unless disabled (
should_export_time_series = False)Preserves system metadata when available, otherwise writes PSY defaults
Patches HDF5 compression, data, owner-type, and metadata-reference fields for InfrastructureSystems.jl compatibility
Lifecycle hooks and controls:
on_validate(): creates the output directory when needed.on_export(): serializes components and supplemental attributes, writes JSON, and optionally exports time-series storage.should_export_time_series: set toFalsebeforerun()to write JSON only.output_path: resolvedPathfor the configured JSON output.
Upgrader¶
SiennaUpgrader¶
Standalone API:
from r2x_core import UpgradeType
upgrader = SiennaUpgrader(path)
result = upgrader.upgrade(upgrade_type=UpgradeType.SYSTEM)
Step registration uses class decorators in upgrade-step modules and semantic version strategy from r2x-core.
run_sienna_upgrades(...)¶
Parser-facing helper that:
Resolves file/folder input from
json_pathorDataStoreDetects/uses current and target versions from context
Runs system upgrades
Migrates legacy HDF5 time series metadata when needed