Migrate to ExaModels macro API, drop concrete keyword - #55
Merged
Conversation
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.
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
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.
This PR updates
ExaModelsPowerto use the macro-based API introduced in ExaModels v0.11 (@add_var,@add_con,@add_con!,@add_obj) and removes theconcretekeyword 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 thecorebinding in the calling scope directly, which required one additional pattern fix inmpopf.jl: helper functions that use macros internally must return the updatedcoreas their first return value, and callers must unpack it:This applies to
build_base_mpopf,add_mpopf_cons,build_mpopf_stor_main,add_piecewise_cons, andadd_smooth_cons.concretekeyword removed (src/opf.jl,src/dcopf.jl,src/mpopf.jl,src/scopf.jl)The
concretekeyword (previously forwarded toExaCore) is dropped. ExaModels v0.11 removesLegacyExaCore;concrete=nothingis now a no-op andconcrete=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 returnscoreas its first value, matching the new callback contract.Breaking changes
ac_opf_model,dc_opf_model,mpopf_model, andgoc3_modelno longer accept aconcretekeyword argument.user_callbackmust now return(core, vars, cons)instead of(vars, cons).Compatibility
Requires ExaModels ≥ 0.11.