feat(sienna): SIENNA connector — load/translate-to-PLEXOS/solve via r2x + Julia - #56
Draft
elasticdotventures wants to merge 1 commit into
Draft
Conversation
…a r2x + Julia) Implements issue Power-Agent#54: a new SIENNA MCP connector exposing load_system, translate_to_plexos, run_sienna_solve, compare_solutions. - powermcp/registry.py: new "sienna" Tool entry mirroring HOPE's Julia precedent (julia_bin/julia_depot_path config_keys, external_solvers=("Julia",)). - SIENNA/sienna_mcp/: main.py + tools/*_tools.py (PSCAD's shape). translate_to_plexos and compare_solutions call r2x (r2x_core/r2x_plexos/r2x_sienna_to_plexos) directly, imported lazily at call time so importing sienna_mcp.main never requires r2x. run_sienna_solve shells out to a bundled Julia driver script (sienna_mcp/scripts/solve_system.jl), the same subprocess mechanism HOPE uses. - SIENNA/pyproject.toml, root pyproject.toml: sienna extra pinning r2x; SIENNA/ force-included in the wheel/sdist build like every other connector. - SIENNA/tests/test_tools.py: mocked tests (PSCAD's MagicMock style) for all four tools; tests/test_vendor_import.py: extended with a license-free import test for sienna_mcp.main (r2x genuinely absent, not just monkeypatched). - SIENNA/README.md: Julia + PowerSystems.jl/PowerSimulations.jl setup, config keys, and a documented, verified-not-assumed gap: the Python r2x_core.System JSON schema and native Julia PowerSystems.jl JSON schema do not round-trip through each other as of r2x 2.1.0 / PowerSystems.jl 5.12.1. run_sienna_solve was verified against a real, freshly-installed Julia 1.10.9 + PowerSystems.jl 5.12.1 + PowerSimulations.jl 0.38.2 + HiGHS.jl 1.24.1: a native Sienna system was built and solved for real (build_status=BUILT, solve_status=SUCCESSFULLY_FINALIZED, objective_value=23039.999999999996). The automated test suite mocks the Julia subprocess rather than re-running that install. tests/ + SIENNA/tests: 122 passed, 4 skipped (pre-existing skips), 0 failures.
5 tasks
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.
Relates to #54. Opened as draft — see reasoning below and the note left on the issue.
Summary
SIENNAconnector:load_system,translate_to_plexos,run_sienna_solve,compare_solutions(PSCAD'smain.py+tools/*_tools.pyshape).powermcp/registry.py: new"sienna"entry mirroringHOPE's Julia precedent (julia_bin/julia_depot_pathconfig keys,external_solvers=("Julia",)).SIENNA/sienna_mcp/_julia.py+scripts/solve_system.jl, standalonepyproject.toml, README, tests.What's verified for real (not mocked)
solve_system.jl:build_status=BUILT,solve_status=SUCCESSFULLY_FINALIZED,objective_value=23039.999999999996.pytest tests/ SIENNA/tests -q→ 122 passed, 4 pre-existing skips, 0 failures. CI/automated tests mock the Julia subprocess itself (a multi-hundred-MB toolchain isn't a reasonable CI dependency) — the real solve above was a manual, one-off verification, not something this PR wires into CI.tests/test_vendor_import.pyrelied onmock.patch.dict(sys.modules, ...), which clears/restores the wholesys.modulessnapshot on exit and was corruptingmcp/pydanticsubmodules loaded mid-test; replaced with a helper that only touches the specific faked keys.Why this is a draft
The Python side (
load_system/translate_to_plexos, viar2x_core.SystemJSON) and the native Julia side (run_sienna_solve, viaPowerSystems.jl's own JSON) turn out not to round-trip through each other — verified with real errors in both directions (VersionNumber(::Nothing)one way,KeyError: 'time_series'the other). So a system loaded viaload_systemcan't currently be fed intorun_sienna_solvewithout a format bridge that doesn't exist yet. Each tool works in isolation (proven above); the connector doesn't yet compose end-to-end. This is a real architectural gap surfaced by testing, not a shortcut — see the note on #54 andSIENNA/README.mdfor detail.r2x_plexos.PLEXOSExporter(export_xml=True)is best-effort — needs config (e.g.horizon_year) a bare Sienna system doesn't carry; failures surface in the tool response rather than raising.Test plan
pytest tests/ SIENNA/tests -qload_system→run_sienna_solveend-to-end (blocked on the JSON-dialect gap)translate_to_plexos(best-effort only)