Skip to content

feat(sienna): SIENNA connector — load/translate-to-PLEXOS/solve via r2x + Julia - #56

Draft
elasticdotventures wants to merge 1 commit into
Power-Agent:mainfrom
elasticdotventures:feat/sienna-connector
Draft

feat(sienna): SIENNA connector — load/translate-to-PLEXOS/solve via r2x + Julia#56
elasticdotventures wants to merge 1 commit into
Power-Agent:mainfrom
elasticdotventures:feat/sienna-connector

Conversation

@elasticdotventures

Copy link
Copy Markdown

Relates to #54. Opened as draft — see reasoning below and the note left on the issue.

Summary

  • New SIENNA connector: load_system, translate_to_plexos, run_sienna_solve, compare_solutions (PSCAD's main.py + tools/*_tools.py shape).
  • powermcp/registry.py: new "sienna" entry mirroring HOPE's Julia precedent (julia_bin/julia_depot_path config keys, external_solvers=("Julia",)).
  • SIENNA/sienna_mcp/_julia.py + scripts/solve_system.jl, standalone pyproject.toml, README, tests.

What's verified for real (not mocked)

  • Installed Julia 1.10.9 + PowerSystems.jl 5.12.1 + PowerSimulations.jl 0.38.2 + HiGHS.jl fresh, built a native Sienna system, and ran a real solve through the connector's own 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.
  • Incidental fix: tests/test_vendor_import.py relied on mock.patch.dict(sys.modules, ...), which clears/restores the whole sys.modules snapshot on exit and was corrupting mcp/pydantic submodules 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, via r2x_core.System JSON) and the native Julia side (run_sienna_solve, via PowerSystems.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 via load_system can't currently be fed into run_sienna_solve without 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 and SIENNA/README.md for detail.

  • Also not completed: PLEXOS XML export via 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 -q
  • Real Julia install + native solve (manual, documented above)
  • load_systemrun_sienna_solve end-to-end (blocked on the JSON-dialect gap)
  • PLEXOS XML export via translate_to_plexos (best-effort only)

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant