Compose spec fragments into a whole model via given - #959
Draft
FabianHofmann wants to merge 2 commits into
Draft
FabianHofmann wants to merge 2 commits into
FabianHofmann wants to merge 2 commits into
Conversation
Re-export math_spec.merge/override from linopy.spec and refuse a spec that still reads a name under given: as a fragment. Guard sits in build_into after normalize_spec, before any data is attached.
Build cost — v1 vs legacyv1 build peak & time relative to legacy, on this commit — not a comparison against master (that is CodSpeed).
Full table (time + peak, mean)📊 Interactive plots + CSV: download the semantics-report-v1-vs-legacy artifact from this run. Report-only · not a gate · refreshed on every push · obsolete once legacy is dropped. |
Collaborator
|
@FabianHofmann Im confused by the pr description The power of Linopy itself just needs to ensure the contract is ok (given variables exist and dims match)? Or does it not work as imago ed? Or is it just the next step? |
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.
Closes # (if applicable).
TODO (human): write your intent by hand here.
Note
The following content was generated by AI.
Stacked on #958. This PR adds math-spec's
given:key through composition, not binding.Changes proposed in this Pull Request
math_spec.mergeandmath_spec.overrideaslinopy.spec.merge/linopy.spec.override. A fragment declares undergiven:the variables and constraints it reads but does not build;mergefolds those reads into the fragment that introduces them,overridelays a patch over a base. Both return a whole-model dict thatModel.from_specbuilds as usual.given.build_into(linopy/spec/accessor.py) raisesValueErrorwhen a spec still reads agiven:name after lowering. The guard sits right afternormalize_specand before any data is attached, so a fragment fails with a clear message instead of a downstream attach or coverage error. This keeps the whole-model-only stance of Build whole models from math-spec (whole-model-only) #958.test/test_spec_composition.pycovers merge/override folding, building and solving a composed model, refusal of a lone fragment and of a merge with no introducer, and a netcdf round-trip.doc/api.rstcomposition note plusspec.merge/spec.overridein the API listing.Warning
math-spec pin is not release-ready.
pyproject.tomlpinsmath-specto thefeat/givenbranch head SHA behind aTODO, because no released alpha shipsmerge/override/Program.givenyet. An alpha tag must be cut fromfeat/givenand the pin updated before merge. #958 must merge first.Checklist
AGENTS.md).doc.doc/release_notes.rstof the upcoming release is included.