CModel accepts a library path, and a fixed library needs no arguments - #1
Merged
Conversation
Mirrors the CNLPModels.jl change, so the two consumers keep one contract. A string is a library PATH when it has a directory part or the platform's shared-library extension, and a search-path NAME otherwise. A path is loaded directly and cached by absolute path, with the prefix defaulting to the file name stripped of lib and the extension; a name resolves against CNLPMODELS_PATH as before. With no arguments, _instantiate consults <prefix>_nargs() — exported by libraries ExaModelsC compiles from a placeholder-free core — and when it reports 0 instantiates through <prefix>_new directly, ignored integer and all. Libraries that do not declare their arity keep the old behaviour. Fixture and tests mirror the Julia repo's (fx prefix: tq fixed at n = 3); disabling the _nargs consult fails exactly the two new tests (14 passed, 1 skipped with it in place).
Mirrors the CNLPModels.jl change: "@opf" resolves the name opf against CNLPMODELS_PATH; any other string is a filesystem path exactly as written ("opf" = file in the current directory, "/path/to/opf" = full path, and a bundle directory resolves to the library inside it). Prefix defaults from the name or the resolved stem. Tests updated to the sigil, including the bare-string-is-a-local-file pin.
Mirrors the CNLPModels.jl fix: dlopen treats a slash-free relative like qp.so as a soname to search the system path for, not as a file in the current directory, so the bare-string semantics only worked where LD_LIBRARY_PATH happened to contain an empty entry. _resolve_path now returns absolute paths. Verified with LD_LIBRARY_PATH scrubbed.
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.
Summary
Mirrors MadNLP/CNLPModels.jl's path + fixed-library support, so the two consumers keep one contract (producer side: madsuite-org/ExaModels.jl#301):
CModelaccepts a library path directly. A string with a directory part or the platform's shared-library extension is loaded directly and cached by absolute path, with the prefix defaulting to the file name stripped ofliband the extension; a bare name resolves againstCNLPMODELS_PATHas before._instantiateconsults<prefix>_nargs()and, when it reports 0, instantiates through<prefix>_newdirectly (ignored integer and all). Libraries that do not declare their arity keep the old behaviour.So
cnlpmodels.CModel("/opt/models/fixed/lib/libfixed.so")is a complete construction.Tests
Fixture and tests mirror the Julia repo's (
fxprefix:tqfixed at n = 3). Disabling the_nargsconsult fails exactly the two new tests; 14 passed, 1 skipped with it in place.🤖 Generated with Claude Code