Skip to content

Migrate to ExaModels macro API, drop concrete keyword - #55

Merged
sshin23 merged 4 commits into
mainfrom
ss/no-concrete
Aug 11, 2026
Merged

Migrate to ExaModels macro API, drop concrete keyword#55
sshin23 merged 4 commits into
mainfrom
ss/no-concrete

Conversation

@sshin23

@sshin23 sshin23 commented Aug 11, 2026

Copy link
Copy Markdown
Member

This PR updates ExaModelsPower to use the macro-based API introduced in ExaModels v0.11 (@add_var, @add_con, @add_con!, @add_obj) and removes the concrete keyword argument from all model-building functions.

Changes

API migration (src/opf.jl, src/dcopf.jl, src/mpopf.jl, src/scopf.jl)

All calls to the function-form API (add_var, variable, constraint, constraint!, objective) are replaced with their macro equivalents. The macros update the core binding in the calling scope directly, which required one additional pattern fix in mpopf.jl: helper functions that use macros internally must return the updated core as their first return value, and callers must unpack it:

# before
vars, cons = build_base_mpopf(core, data, N)

# after
core, vars, cons = build_base_mpopf(core, data, N)

This applies to build_base_mpopf, add_mpopf_cons, build_mpopf_stor_main, add_piecewise_cons, and add_smooth_cons.

concrete keyword removed (src/opf.jl, src/dcopf.jl, src/mpopf.jl, src/scopf.jl)

The concrete keyword (previously forwarded to ExaCore) is dropped. ExaModels v0.11 removes LegacyExaCore; concrete=nothing is now a no-op and concrete=Val(false) is no longer supported.

Test suite (test/runtests.jl)

add_electrolyzers (the user-callback example) is updated to use the macro API and now returns core as its first value, matching the new callback contract.

Breaking changes

  • ac_opf_model, dc_opf_model, mpopf_model, and goc3_model no longer accept a concrete keyword argument.
  • User callbacks passed via user_callback must now return (core, vars, cons) instead of (vars, cons).

Compatibility

Requires ExaModels ≥ 0.11.

Replace all function-form ExaModels API calls (add_var, variable,
constraint, constraint!, objective) with macro equivalents (@add_var,
@add_con, @add_con!, @add_obj) across opf.jl, dcopf.jl, mpopf.jl,
and scopf.jl.

Helper functions in mpopf.jl that use macros internally now return
the updated core as their first return value; callers unpack with
core, vars, cons = helper(...).

Remove the concrete keyword argument from all model-building functions.
ExaModels v0.11 removes LegacyExaCore; concrete=nothing is a no-op
and concrete=Val(false) is no longer supported.

Update the user_callback contract: callbacks must now return
(core, vars, cons) instead of (vars, cons). Update add_electrolyzers
in test/runtests.jl accordingly.

Requires ExaModels >= 0.11.
@sshin23
sshin23 merged commit 4387af3 into main Aug 11, 2026
2 checks passed
@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.48156% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.86%. Comparing base (17e4f13) to head (b938830).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/scopf.jl 98.18% 6 Missing ⚠️
src/mpopf.jl 98.61% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main      #55   +/-   ##
=======================================
  Coverage   88.86%   88.86%           
=======================================
  Files           9        9           
  Lines        1275     1275           
=======================================
  Hits         1133     1133           
  Misses        142      142           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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